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
Copy file name to clipboardExpand all lines: README.md
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,16 +93,17 @@ await act(async () => {
93
93
94
94
Configuration options for the test renderer. Many of these options correspond to React Reconciler configuration options. For detailed information about reconciler-specific options, refer to the [React Reconciler source code](https://github.com/facebook/react/tree/main/packages/react-reconciler).
|`textComponentTypes`|`string[]`| Types of host components that are allowed to contain text nodes. Trying to render text outside of these components will throw an error. Useful for simulating React Native's text rendering rules. |
99
-
|`publicTextComponentTypes`|`string[]`| Host component types to display to users in error messages when they try to render text outside of `textComponentTypes`. Defaults to `textComponentTypes` if not provided. |
100
-
|`createNodeMock`|`(element: ReactElement) => object`| Function to create mock objects for refs. Called once per element that has a ref. Defaults to returning an empty object. |
101
-
|`identifierPrefix`|`string`| A string prefix React uses for IDs generated by `useId()`. Useful to avoid conflicts when using multiple roots. |
102
-
|`isStrictMode`|`boolean`| Enable React Strict Mode. When enabled, components render twice and effects run twice in development. |
103
-
|`onCaughtError`|`(error: unknown, errorInfo: { componentStack?: string }) => void`| Callback called when React catches an error in an Error Boundary. Called with the error caught by the Error Boundary and an errorInfo object containing the component stack. |
104
-
|`onUncaughtError`|`(error: unknown, errorInfo: { componentStack?: string }) => void`| Callback called when an error is thrown and not caught by an Error Boundary. Called with the error that was thrown and an errorInfo object containing the component stack. |
105
-
|`onRecoverableError`|`(error: unknown, errorInfo: { componentStack?: string }) => void`| Callback called when React automatically recovers from errors. Called with an error React throws and an errorInfo object containing the component stack. Some recoverable errors may include the original error cause as `error.cause`. |
|`textComponentTypes`|`string[]`| Types of host components that are allowed to contain text nodes. Trying to render text outside of these components will throw an error. Useful for simulating React Native's text rendering rules. |
99
+
|`publicTextComponentTypes`|`string[]`| Host component types to display to users in error messages when they try to render text outside of `textComponentTypes`. Defaults to `textComponentTypes` if not provided. |
100
+
|`createNodeMock`|`(element: ReactElement) => object`| Function to create mock objects for refs. Called once per element that has a ref. Defaults to returning an empty object. |
101
+
|`transformHiddenInstanceProps`|`({ props, type }: { props: Record<string, unknown>; type: string }) => Record<string, unknown>`| Transforms host instance props when React marks an instance as hidden (for example, while Suspense fallback is shown). Return a new props object instead of mutating the provided one. When provided, hidden instances stay visible in `children` and `toJSON()` output using transformed props. |
102
+
|`identifierPrefix`|`string`| A string prefix React uses for IDs generated by `useId()`. Useful to avoid conflicts when using multiple roots. |
103
+
|`isStrictMode`|`boolean`| Enable React Strict Mode. When enabled, components render twice and effects run twice in development. |
104
+
|`onCaughtError`|`(error: unknown, errorInfo: { componentStack?: string }) => void`| Callback called when React catches an error in an Error Boundary. Called with the error caught by the Error Boundary and an errorInfo object containing the component stack. |
105
+
|`onUncaughtError`|`(error: unknown, errorInfo: { componentStack?: string }) => void`| Callback called when an error is thrown and not caught by an Error Boundary. Called with the error that was thrown and an errorInfo object containing the component stack. |
106
+
|`onRecoverableError`|`(error: unknown, errorInfo: { componentStack?: string }) => void`| Callback called when React automatically recovers from errors. Called with an error React throws and an errorInfo object containing the component stack. Some recoverable errors may include the original error cause as `error.cause`. |
106
107
107
108
### `TestInstance` {#test-instance}
108
109
@@ -112,13 +113,13 @@ A wrapper around rendered host elements with a DOM-like API for querying and ins
112
113
113
114
-`type: string`: The element type (e.g., `"View"`, `"div"`). Returns an empty string for the container element.
114
115
-`props: Record<string, all>`: The element's props object.
115
-
-`children: HostNode[]`: Array of child nodes (elements and text strings). Hidden children are excluded.
116
+
-`children: HostNode[]`: Array of child nodes (elements and text strings). Hidden children are excluded by default, but are included when `transformHiddenInstanceProps` is configured.
116
117
-`parent: TestInstance | null`: The parent element, or `null` if this is the root container.
117
118
-`unstable_fiber: Fiber | null`: Access to the underlying React Fiber node. **Warning:** This is an unstable API that exposes internal React Reconciler structures which may change without warning in future React versions. Use with caution and only when absolutely necessary.
118
119
119
120
**Methods:**
120
121
121
-
-`toJSON(): JsonElement | null`: Converts this element to a JSON representation suitable for snapshots. Returns `null`if the element is hidden.
122
+
-`toJSON(): JsonElement | null`: Converts this element to a JSON representation suitable for snapshots. Returns `null`for hidden elements only when `transformHiddenInstanceProps`is not configured.
122
123
-`queryAll(predicate: (instance: TestInstance) => boolean, options?: QueryOptions): TestInstance[]`: Finds all descendant elements matching the predicate. See [Query Options](#query-options) below.
/** Callback called when React catches an error in an Error Boundary. Called with the error caught by the Error Boundary, and an errorInfo object containing the componentStack. */
44
51
onCaughtError?: ErrorHandler;
45
52
@@ -94,6 +101,7 @@ export function createRoot(options?: RootOptions): Root {
0 commit comments