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
@@ -86,6 +85,40 @@ Latest `render` result is kept in [`screen`](#screen) variable that can be impor
86
85
Using `screen` instead of destructuring `render` result is recommended approach. See [this article](https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#not-using-screen) from Kent C. Dodds for more details.
87
86
:::
88
87
88
+
### `render` options
89
+
90
+
The behavior of `render` method can be customized by passing various options as a second argument of `RenderOptions` type:
91
+
92
+
#### `wrapper` option
93
+
94
+
```ts
95
+
wrapper?:React.ComponentType<any>,
96
+
```
97
+
98
+
This options allows you to wrap tested component, passed as the first option to the `render()` function, in additional wrapper component. This is most useful for creating reusable custom render functions for common React Context providers.
This options allows you to pass `createNodeMock` option to `ReactTestRenderer.create()` method in order to allow for custom mock refs. You can learn more about this options from [React Test Renderer documentation](https://reactjs.org/docs/test-renderer.html#ideas).
This options is experimental, in some cases it might not work as intended, and its behavior might change without observing [SemVer](https://semver.org/) requirements for breaking changes.
116
+
:::
117
+
118
+
This **experimental** option allows you to replicate React Native behavior of throwing `Invariant Violation: Text strings must be rendered within a <Text> component` error when you try to render `string` value under components different than `<Text>`, e.g. under `<View>`.
119
+
120
+
This check is not enforced by React Test Renderer and hence by default React Native Testing Library also does not check this. That might result in runtime errors when running your code on a device, while the code works without errors in tests.
121
+
89
122
### `...queries`
90
123
91
124
The most important feature of `render` is providing a set of helpful queries that allow you to find certain elements in the view hierarchy.
0 commit comments