@@ -26,17 +26,18 @@ export const flushMicrotasksQueue = (): Promise<any> =>
26
26
* Renders test component deeply using react-test-renderer and exposes helpers
27
27
* to assert on the output.
28
28
*/
29
- export const render = ( component : React . Element < * > ) => {
30
- const renderer = TestRenderer . create ( component ) ;
29
+ export const render = (
30
+ component : React . Element < * > ,
31
+ options ?: { createNodeMock : ( element : React . Element < * > ) => any }
32
+ ) => {
33
+ const renderer = TestRenderer . create ( component , options ) ;
31
34
const instance = renderer . root ;
32
35
33
36
return {
34
- instance,
35
- renderer,
36
37
getByTestId : ( testID : string ) => instance . findByProps ( { testID } ) ,
37
- getByName : ( name : string ) =>
38
+ getByName : ( name : string | React . Element < * > ) =>
38
39
instance . find ( node => getNodeByName ( node , name ) ) ,
39
- getAllByName : ( name : string ) =>
40
+ getAllByName : ( name : string | React . Element < * > ) =>
40
41
instance . findAll ( node => getNodeByName ( node , name ) ) ,
41
42
getByText : ( text : string | RegExp ) =>
42
43
instance . find ( node => getNodeByText ( node , text ) ) ,
@@ -46,6 +47,8 @@ export const render = (component: React.Element<*>) => {
46
47
instance . findByProps ( props ) ,
47
48
getAllByProps : ( props : { [ propName : string ] : any } ) =>
48
49
instance . findAllByProps ( props ) ,
50
+ update : renderer . update ,
51
+ unmount : renderer . unmount ,
49
52
} ;
50
53
} ;
51
54
0 commit comments