File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { Text , TextInput , View } from 'react-native' ;
3
3
import TestRenderer from 'react-test-renderer' ;
4
+ import type { ReactTestRenderer } from 'react-test-renderer' ;
4
5
import { configureInternal , getConfig , HostComponentNames } from '../config' ;
5
6
import { getQueriesForElement } from '../within' ;
6
7
@@ -29,12 +30,19 @@ export function configureHostComponentNamesIfNeeded() {
29
30
30
31
function detectHostComponentNames ( ) : HostComponentNames {
31
32
try {
32
- const renderer = TestRenderer . create (
33
- < View >
34
- < Text testID = "text" > Hello</ Text >
35
- < TextInput testID = "textInput" />
36
- </ View >
37
- ) ;
33
+ const renderer = ( ( ) => {
34
+ let result : ReactTestRenderer ;
35
+ TestRenderer . act ( ( ) => {
36
+ result = TestRenderer . create (
37
+ < View >
38
+ < Text testID = "text" > Hello</ Text >
39
+ < TextInput testID = "textInput" />
40
+ </ View >
41
+ ) ;
42
+ } ) ;
43
+ // @ts -ignore act is sync, so renderer is always initialised here
44
+ return result ;
45
+ } ) ( ) ;
38
46
39
47
const { getByTestId } = getQueriesForElement ( renderer . root ) ;
40
48
const textHostName = getByTestId ( 'text' ) . type ;
You can’t perform that action at this time.
0 commit comments