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 ShallowRenderer =require('react-test-renderer/shallow'); // ES5 with npm
13
+
var ShallowRenderer =require('react-test-renderer/shallow'); // ES5 z zainstalowanym npm
14
14
```
15
15
16
-
## Overview {#overview}
16
+
## Ogólne informacje {#overview}
17
17
18
-
When writing unit tests for React, shallow rendering can be helpful. Shallow rendering lets you render a component "one level deep" and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM.
18
+
Podczas pisania testów jednostkowych dla kodu reactowego przydatne może okazać się renderowanie płytkie (ang. *shallow rendering*). Pozwala ono na wyrenderowanie komponentu "jeden poziom w głąb" i wykonanie sprawdzeń na zwróconym drzewie, bez obaw o efekty uboczne komponentów potomnych, które wcale nie są tworzone i renderowane. Proces ten nie wymaga obecności drzewa DOM.
19
19
20
-
For example, if you have the following component:
20
+
Załóżmy, że mamy do czynienia z następującym komponentem:
Shallow testing currently has some limitations, namely not supporting refs.
50
+
Testowanie płytkie posiada obecnie pewne ograniczenia, jak choćby brak wsparcia dla referencji (ang. *refs*) komponentów.
51
51
52
-
> Note:
52
+
> Uwaga:
53
53
>
54
-
> We also recommend checking out Enzyme's [Shallow Rendering API](http://airbnb.io/enzyme/docs/api/shallow.html). It provides a nicer higher-level API over the same functionality.
54
+
> Zalecamy również zapoznanie się z [interefejsem API do płytkiego renderowania](http://airbnb.io/enzyme/docs/api/shallow.html) biblioteki Enzyme. Dostarcza ona tę samą funkcjonalność, jednak ma wygodniejszy i bardziej wysokopoziomowy interfejs.
You can think of the shallowRenderer as a "place" to render the component you're testing, and from which you can extract the component's output.
60
+
`shallowRenderer` jest "miejscem", w którym można wyrenderować testowany komponent i otrzymać zwracaną przez niego strukturę.
61
61
62
-
`shallowRenderer.render()`is similar to[`ReactDOM.render()`](/docs/react-dom.html#render) but it doesn't require DOM and only renders a single level deep. This means you can test components isolated from how their children are implemented.
62
+
`shallowRenderer.render()`w działaniu przypomina[`ReactDOM.render()`](/docs/react-dom.html#render), jednak nie wymaga obecności drzewa DOM, a ponadto renderuje tylko jeden poziom struktury. Oznacza to, iż doskonale nadaje się do testowania komponentów w izolacji, bez brania pod uwagę implementacji komponentów potomnych.
0 commit comments