You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var ReactTestUtils =require('react-dom/test-utils'); // ES5 with npm
13
+
var ReactTestUtils =require('react-dom/test-utils'); // ES5 dengan npm
14
14
```
15
15
16
-
## Overview {#overview}
16
+
## Ikhtisar {#ikhtisar}
17
17
18
-
`ReactTestUtils`makes it easy to test React components in the testing framework of your choice. At Facebook we use[Jest](https://facebook.github.io/jest/)for painless JavaScript testing. Learn how to get started with Jest through the Jest website's[React Tutorial](https://jestjs.io/docs/tutorial-react).
18
+
`ReactTestUtils`mempermudah kita melakukan tes pada komponen React dengan _framework_ tes pilihan anda. Di Facebook kami menggunakan[Jest](https://facebook.github.io/jest/)untuk tes JavaScript yang tidak merepotkan. Belajar cara mulai menggunakan Jest melalui situs Jest [React Tutorial](https://jestjs.io/docs/tutorial-react).
19
19
20
-
> Note:
20
+
> Catatan:
21
21
>
22
-
> We recommend using [`react-testing-library`](https://git.io/react-testing-library)which is designed to enable and encourage writing tests that use your components as the end users do.
22
+
> Kami menyarankan Anda untuk menggunakan [`react-testing-library`](https://git.io/react-testing-library)yang didesain untuk memfasilitasi dan mendorong penulisan tes yang menggunakan komponen anda selayaknya seorang pengguna sebenarnya.
23
23
>
24
-
> Alternatively, Airbnb has released a testing utility called [Enzyme](https://airbnb.io/enzyme/), which makes it easy to assert, manipulate, and traverse your React Components' output.
24
+
> Pilihan lain, Airbnb telah merilis utilitas tes bernama [Enzyme](https://airbnb.io/enzyme/), yang mempermudah kita dalam menyatakan, memanipulasi, dan melewati keluaran dari komponen React anda.
25
25
26
26
-[`act()`](#act)
27
27
-[`mockComponent()`](#mockcomponent)
@@ -40,17 +40,17 @@ var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
40
40
-[`renderIntoDocument()`](#renderintodocument)
41
41
-[`Simulate`](#simulate)
42
42
43
-
## Reference {#reference}
43
+
## Referensi {#referensi}
44
44
45
45
### `act()` {#act}
46
46
47
-
To prepare a component for assertions, wrap the code rendering it and performing updates inside an `act()` call. This makes your test run closer to how React works in the browser.
47
+
Untuk menyiapkan komponen sebelum penegasan, bungkus kode yang me-*render* komponen tersebut dan lakukan pembaruan di dalam panggilan `act()`. Hal ini membuat tes anda berjalan menyerupai bagaimana React bekerja di peramban.
48
48
49
-
>Note
49
+
>Catatan
50
50
>
51
-
>If you use`react-test-renderer`, it also provides an`act`export that behaves the same way.
51
+
>Jika Anda menggunakan`react-test-renderer`, `react-test-renderer` juga menyediakan sebuah`act`ekspor yang sama.
52
52
53
-
For example, let's say we have this `Counter`component:
53
+
Sebagai contoh, katakanlah kita punya `Counter`komponen:
54
54
55
55
```js
56
56
classAppextendsReact.Component {
@@ -60,10 +60,10 @@ class App extends React.Component {
expect(label.textContent).toBe('Anda menekan sebanyak 1 kali');
121
+
expect(document.title).toBe('Anda menekan sebanyak 1 kali');
122
122
});
123
123
```
124
124
125
-
Don't forget that dispatching DOM events only works when the DOM container is added to the `document`. You can use a helper like [`react-testing-library`](https://github.com/kentcdodds/react-testing-library)to reduce the boilerplate code.
125
+
Jangan lupa dalam mengirim perihal DOM hanya dapat dilakukan ketika penampung DOM sudah ditambahkan ke `document`. Anda dapat menggunakan penunjang seperti [`react-testing-library`](https://github.com/kentcdodds/react-testing-library)untuk mengurangi kode _boilerplate_.
126
126
127
127
* * *
128
128
@@ -135,11 +135,12 @@ mockComponent(
135
135
)
136
136
```
137
137
138
-
Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple `<div>`(or other tag if `mockTagName`is provided) containing any provided children.
138
+
Oper sebuah komponen tiruan ke _method_ ini untuk menambahkan _method-method_ berguna yang memperbolehkan komponen tersebut untuk digunakan sebagai komponen React tiruan. Sebagai ganti dari _rendering_ seperti biasa, komponen tiruan ini akan menjadi `<div>`sederhana (atau tag lain jika `mockTagName`disediakan) yang menampung anak komponen yang disediakan.
139
139
140
-
> Note:
140
+
> Catatan:
141
141
>
142
-
> `mockComponent()` is a legacy API. We recommend using [shallow rendering](/docs/shallow-renderer.html) or [`jest.mock()`](https://facebook.github.io/jest/docs/en/tutorial-react-native.html#mock-native-modules-using-jestmock) instead.
142
+
143
+
> `mockComponent()` adalah sebuah API peninggalan. Kami menyarankan Anda menggunakan [shallow rendering](/docs/shallow-renderer.html) atau [`jest.mock()`](https://facebook.github.io/jest/docs/en/tutorial-react-native.html#mock-native-modules-using-jestmock).
143
144
144
145
* * *
145
146
@@ -149,7 +150,7 @@ Pass a mocked component module to this method to augment it with useful methods
149
150
isElement(element)
150
151
```
151
152
152
-
Returns`true`if`element`is any React element.
153
+
Mengembalikan`true`jika`element`adalah sebuah React elemen.
153
154
154
155
* * *
155
156
@@ -162,7 +163,7 @@ isElementOfType(
162
163
)
163
164
```
164
165
165
-
Returns`true`if`element`is a React element whose type is of a React `componentClass`.
166
+
Mengembalikan`true`jika`element`adalah sebuah React elemen yang memiliki tipe dari React `componentClass`.
166
167
167
168
* * *
168
169
@@ -172,7 +173,7 @@ Returns `true` if `element` is a React element whose type is of a React `compone
172
173
isDOMComponent(instance)
173
174
```
174
175
175
-
Returns`true`if`instance`is a DOM component (such as a `<div>`or`<span>`).
176
+
Mengembalikan`true`jika`instance`adalah sebuah komponen DOM (seperti sebuah `<div>`atau`<span>`).
176
177
177
178
* * *
178
179
@@ -182,7 +183,7 @@ Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
182
183
isCompositeComponent(instance)
183
184
```
184
185
185
-
Returns`true`if`instance`is a user-defined component, such as a class or a function.
186
+
Mengembalikan`true`jika`instance`adalah sebuah komponen yang ditetapkan oleh pengguna, seperti sebuah kelas atau sebuah fungsi.
186
187
187
188
* * *
188
189
@@ -195,7 +196,7 @@ isCompositeComponentWithType(
195
196
)
196
197
```
197
198
198
-
Returns`true`if`instance`is a component whose type is of a React `componentClass`.
199
+
Mengembalikan`true`jika`instance`adalah sebuah komponen yang memiliki tipe dari React `componentClass`.
199
200
200
201
* * *
201
202
@@ -208,7 +209,7 @@ findAllInRenderedTree(
208
209
)
209
210
```
210
211
211
-
Traverse all components in`tree`and accumulate all components where`test(component)`is`true`. This is not that useful on its own, but it's used as a primitive for other test utils.
212
+
Melewati semua komponen dalam`tree`dan mengumpulkan semua komponen yang`test(component)`adalah`true`. Ini tidak begitu bermanfaat dengan dirinya sendiri, tetapi digunakan sebagai primitif untuk alat uji lainnya.
Like[`scryRenderedDOMComponentsWithClass()`](#scryrendereddomcomponentswithclass)but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
238
+
Seperti[`scryRenderedDOMComponentsWithClass()`](#scryrendereddomcomponentswithclass)tetapi mengharapkan satu hasil dan mengembalikan satu hasil tersebut atau melempar _exception_ jika ada lebih dari satu yang cocok.
Like[`scryRenderedDOMComponentsWithTag()`](#scryrendereddomcomponentswithtag)but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
264
+
Seperti[`scryRenderedDOMComponentsWithTag()`](#scryrendereddomcomponentswithtag)tetapi mengharapkan satu hasil dan mengembalikan satu hasil tersebut atau melempar _exception_ jika ada lebih dari satu yang cocok.
Same as[`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype)but expects there to be one result and returns that one result, or throws exception if there is any other number of matches besides one.
290
+
Sama seperti[`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype)tetapi mengharapkan satu hasil dan mengembalikan satu hasil tersebut atau melempar _exception_ jika ada lebih dari satu yang cocok.
290
291
291
292
***
292
293
@@ -296,16 +297,16 @@ Same as [`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype) bu
296
297
renderIntoDocument(element)
297
298
```
298
299
299
-
Render a React element into a detached DOM node in the document. **This function requires a DOM.**It is effectively equivalent to:
300
+
Menggambar sebuah elemen React ke dalam sebuah DOM _node_ terpisah dalam _document_. **Fungsi ini membutuhkan sebuah DOM.**Secara efektif hal ini sama dengan:
300
301
301
302
```js
302
303
constdomContainer=document.createElement('div');
303
304
ReactDOM.render(element, domContainer);
304
305
```
305
306
306
-
> Note:
307
+
> Catatan:
307
308
>
308
-
> You will need to have `window`, `window.document`and`window.document.createElement`globally available **before**you import `React`. Otherwise React will think it can't access the DOM and methods like`setState`won't work.
309
+
> Anda harus memiliki `window`, `window.document`dan`window.document.createElement`tersedia secara global **sebelum**Anda import `React`. Jika tidak React akan berpikir tidak dapat mengakses DOM dan _method-method_ seperti`setState`tidak akan bekerja.
309
310
310
311
* * *
311
312
@@ -320,30 +321,30 @@ Simulate.{eventName}(
320
321
)
321
322
```
322
323
323
-
Simulate an event dispatch on a DOM node with optional`eventData`event data.
324
+
Mensimulasikan pengiriman sebuah perihal pada suatu DOM _node_ dengan pilihan`eventData`_event_ data.
324
325
325
-
`Simulate`has a method for[every event that React understands](/docs/events.html#supported-events).
326
+
`Simulate`memiliki sebuah _method_ untuk[every event that React understands](/docs/events.html#supported-events).
> You will have to provide any event property that you're using in your component (e.g. keyCode, which, etc...) as React is not creating any of these for you.
348
+
> Anda harus menyediakan _event_ properti yang Anda gunakan dalam komponen (contoh keyCode, which, dll...) karena React tidak membuat _event_ tersebut untuk Anda.
0 commit comments