1
1
import * as React from 'react' ;
2
- import type { HostElement , Root } from 'universal-test-renderer/react-native ' ;
3
- import { createRoot } from 'universal-test-renderer/react-native ' ;
2
+ import type { HostElement , Root , RootOptions } from 'universal-test-renderer' ;
3
+ import { createRoot } from 'universal-test-renderer' ;
4
4
5
5
import act from './act' ;
6
6
import { addToCleanupQueue } from './cleanup' ;
7
7
import { getConfig } from './config' ;
8
8
import type { DebugOptions } from './helpers/debug' ;
9
9
import { debug } from './helpers/debug' ;
10
+ import { HOST_TEXT_NAMES } from './helpers/host-component-names' ;
10
11
import { setRenderResult } from './screen' ;
11
12
import { getQueriesForElement } from './within' ;
12
13
@@ -22,19 +23,20 @@ export interface RenderOptions {
22
23
23
24
export type RenderResult = ReturnType < typeof render > ;
24
25
26
+ const createRootOptions : RootOptions = {
27
+ textComponents : HOST_TEXT_NAMES ,
28
+ } ;
29
+
25
30
/**
26
31
* Renders test component deeply using React Test Renderer and exposes helpers
27
32
* to assert on the output.
28
33
*/
29
- export default function render < T > ( element : React . ReactElement < T > , options : RenderOptions = { } ) {
30
- return renderInternal ( element , options ) ;
31
- }
32
-
33
- export function renderInternal < T > ( element : React . ReactElement < T > , options ?: RenderOptions ) {
34
+ export function render < T > ( element : React . ReactElement < T > , options : RenderOptions = { } ) {
34
35
const { wrapper : Wrapper } = options || { } ;
35
36
36
37
const wrap = ( element : React . ReactElement ) => ( Wrapper ? < Wrapper > { element } </ Wrapper > : element ) ;
37
38
const renderer = createRoot ( {
39
+ ...createRootOptions ,
38
40
createNodeMock : options ?. createNodeMock ,
39
41
} ) ;
40
42
void act ( ( ) => {
0 commit comments