@@ -3,7 +3,7 @@ import '@shopify/flash-list/jestSetup';
33import { BottomSheetModalProvider } from '@gorhom/bottom-sheet' ;
44import { NavigationContainer } from '@react-navigation/native' ;
55import type { RenderOptions } from '@testing-library/react-native' ;
6- import { render } from '@testing-library/react-native' ;
6+ import { render , userEvent } from '@testing-library/react-native' ;
77import type { ReactElement } from 'react' ;
88import React from 'react' ;
99
@@ -17,11 +17,23 @@ const createAppWrapper = () => {
1717
1818const customRender = (
1919 ui : ReactElement ,
20- options ?: Omit < RenderOptions , 'wrapper' >
20+ options ?: Omit < RenderOptions , 'wrapper' > ,
2121) => {
2222 const Wrapper = createAppWrapper ( ) ; // make sure we have a new wrapper for each render
2323 return render ( ui , { wrapper : Wrapper , ...options } ) ;
2424} ;
2525
26+ // use this if you want to test user events
27+ export const setup = (
28+ ui : ReactElement ,
29+ options ?: Omit < RenderOptions , 'wrapper' > ,
30+ ) => {
31+ const Wrapper = createAppWrapper ( ) ;
32+ return {
33+ user : userEvent . setup ( ) ,
34+ ...render ( ui , { wrapper : Wrapper , ...options } ) ,
35+ } ;
36+ } ;
37+
2638export * from '@testing-library/react-native' ;
2739export { customRender as render } ;
0 commit comments