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
constTestRenderer=require('react-test-renderer'); //ES5 with npm
13
+
constTestRenderer=require('react-test-renderer'); //npm ilə ES5
14
14
```
15
15
16
-
## Overview {#overview}
16
+
## İcmal {#overview}
17
17
18
-
This package provides a React renderer that can be used to render React components to pure JavaScript objects, without depending on the DOM or a native mobile environment.
18
+
Bu paket, React komponentlərini Javascript obyektlərinə render etmək üçün, DOM və ya nativ mobil mühitindən asılı olmayan React renderer-i təmin edir.
19
19
20
-
Essentially, this package makes it easy to grab a snapshot of the platform view hierarchy (similar to a DOM tree) rendered by a React DOM or React Native component without using a browser or [jsdom](https://github.com/tmpvar/jsdom).
20
+
Bu paket, React DOM və ya React Native komponentinin, brauzer və ya [jsdom](https://github.com/tmpvar/jsdom) olmadan render etdiyi platforma görünüş iyerarxiyasının snəpşotunu asan formada çəkməyə imkan yaradır.
You can use Jest's snapshot testing feature to automatically save a copy of the JSON tree to a file and check in your tests that it hasn't changed: [Learn more about it](https://jestjs.io/docs/en/snapshot-testing).
41
+
JSON ağacının kopiyasını yadda saxlayıb testlərdə bu ağacın dəyişdiyini yoxlamaq üçün Jest-in snəpşot test xüsusiyyətindən istifadə edə bilərsiniz. [Əlavə məlumat üçün bura baxın](https://jestjs.io/docs/en/snapshot-testing).
42
42
43
-
You can also traverse the output to find specific nodes and make assertions about them.
43
+
Həmçinin siz nəticənin üzərindən keçib lazım olan nodları tapa bilər və bu nodlar üzərində iddialarınızı yoxlaya bilərsiniz.
Create a `TestRenderer`instance with the passed React element. It doesn't use the real DOM, but it still fully renders the component tree into memory so you can make assertions about it. Returns a [TestRenderer instance](#testrenderer-instance).
106
+
Göndərilən React elementi ilə `TestRenderer`instansiyası yaradın. Bunun real DOM-dan istifadə etməməsinə baxmayaraq, iddialarımızı yoxlaya bilmək üçün komponent ağacı yenə də bütünlüklə yaddaşa render edilir. Qaytarılan instansiyanın funksiya və parametrləri aşağıda göstərilib.
107
107
108
108
### `TestRenderer.act()` {#testrendereract}
109
109
110
110
```javascript
111
111
TestRenderer.act(callback);
112
112
```
113
113
114
-
Similar to the [`act()` helper from `react-dom/test-utils`](/docs/test-utils.html#act), `TestRenderer.act` prepares a component for assertions. Use this version of `act()` to wrap calls to `TestRenderer.create`and`testRenderer.update`.
114
+
`TestRenderer.act`, [`react-dom/test-utils`-də olan `act()` köməkçisi kimi](/docs/test-utils.html#act) iddialarınızı yoxlamaq üçün komponentləri hazırlayır. `act()`-in bu versiyasını `TestRenderer.create`və`testRenderer.update` çağırışlarını əhatə etmək üçün işlədin.
115
115
116
116
```javascript
117
117
import {create, act} from'react-test-renderer';
118
-
importAppfrom'./app.js'; //The component being tested
Return an object representing the rendered tree. This tree only contains the platform-specific nodes like `<div>`or `<View>`and their props, but doesn't contain any user-written components. This is handy for [snapshot testing](https://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshot-testing-with-jest).
145
+
Render edilmiş ağacı təmsil edən obyekti qaytarır. Render edilmiş ağac yalnız `<div>`və ya `<View>`kimi platform-spesifik nodlardan ibarətdir. Bu ağacda istifadəçi tərəfindən yaranmış komponentlər olmur. [Snəpşot testi üçün](https://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshot-testing-with-jest) faydalıdır.
145
146
146
147
### `testRenderer.toTree()` {#testrenderertotree}
147
148
148
149
```javascript
149
150
testRenderer.toTree()
150
151
```
151
152
152
-
Return an object representing the rendered tree. Unlike `toJSON()`, the representation is more detailed than the one provided by `toJSON()`, and includes the user-written components. You probably don't need this method unless you're writing your own assertion library on top of the test renderer.
153
+
Render edilmiş ağacı təmsil edən obyekti qaytarır. `toJSON()`-dan fərqli olaraq bu funksiya istifadəçi tərəfindən yaranmış komponentləri də obyektə daxil edir. Siz test renderer üzərində öz test kitabxananızı yazmırsınızsa, bu funksiya sizə lazım deyil.
153
154
154
155
### `testRenderer.update()` {#testrendererupdate}
155
156
156
157
```javascript
157
158
testRenderer.update(element)
158
159
```
159
160
160
-
Re-render the in-memory tree with a new root element. This simulates a React update at the root. If the new element has the same type and key as the previous element, the tree will be updated; otherwise, it will re-mount a new tree.
161
+
Yaddaşda olan ağacı yeni ana elementi ilə yenidən render edin. Bu funksiya React-in ana komponentdə yenilənməsini simulyasiya edir. Əgər yeni elementin tipi və açarı keçmiş elementinki ilə eynidirsə ağac yenilənəcək. Əks halda yeni ağac mount olunacaq.
Return the instance corresponding to the root element, if available. This will not work if the root element is a function component because they don't have instances.
177
+
Əgər mümkündürsə, ana elementin instansiyasını qaytarın. Əgər ana element funksiya komponentidirsə bu funksiya işləməyəcək. Çünki funksiya komponentlərinin instansiyaları olmur.
177
178
178
179
### `testRenderer.root` {#testrendererroot}
179
180
180
181
```javascript
181
182
testRenderer.root
182
183
```
183
184
184
-
Returns the root "test instance" object that is useful for making assertions about specific nodes in the tree. You can use it to find other "test instances" deeper below.
185
+
Ağacda olan spesifik nodlar haqqında iddiaları yaratmaq üçün faydalı olan ana "test instansiya" obyektini qaytarın. Siz bu instansiya ilə dərində olan digər "test instansiyalarını" tapa bilərsiniz.
185
186
186
187
### `testInstance.find()` {#testinstancefind}
187
188
188
189
```javascript
189
190
testInstance.find(test)
190
191
```
191
192
192
-
Find a single descendant test instance for which `test(testInstance)`returns `true`. If`test(testInstance)`does not return `true`for exactly one test instance, it will throw an error.
193
+
`test(testInstance)``true` qaytaran tək test instansiyasını tapın. Əgər`test(testInstance)`yalnız tək instansiya üçün `true`qaytarmırsa bu funksiya istisna atacaq.
Find a single descendant test instance with the provided `type`. If there is not exactly one test instance with the provided `type`, it will throw an error.
201
+
Təmin edilən `type` ilə tək test instansiyasını tapın. Əgər təmin edilən `type` ilə yalnız tək instansiya yoxdursa bu funksiya istisna atacaq.
Find a single descendant test instance with the provided `props`. If there is not exactly one test instance with the provided `props`, it will throw an error.
209
+
Təmin edilən `props` ilə tək test instansiyasını tapın. Əgər təmin edilən `props` ilə yalnız tək instansiya yoxdursa, bu funksiya istisna atacaq.
The component instance corresponding to this test instance. It is only available for class components, as function components don't have instances. It matches the `this`value inside the given component.
241
+
Göstərilən test instansiyasına uyğun olan komponent. Funksiya komponentlərinin instansiyaları olmadığından bu yalnız klas komponentləri üçün mövcuddur. Verilən komponentin `this`dəyəri ilə uyğundur.
241
242
242
243
### `testInstance.type` {#testinstancetype}
243
244
244
245
```javascript
245
246
testInstance.type
246
247
```
247
248
248
-
The component type corresponding to this test instance. For example, a `<Button />`component has a type of `Button`.
249
+
Test instansiyasının komponent tipi. Məsələn, `<Button />`komponentinin tipi `Button`-dır.
249
250
250
251
### `testInstance.props` {#testinstanceprops}
251
252
252
253
```javascript
253
254
testInstance.props
254
255
```
255
256
256
-
The props corresponding to this test instance. For example, a `<Button size="small" />`component has `{size: 'small'}`as props.
257
+
Test instansiyasına uyğun gələn proplar. Məsələn, `<Button size="small" />`komponentinin `{size: 'small'}`propları var.
0 commit comments