test-utils.js (639B)
1 // test-utils.js 2 import React from 'react'; 3 import { render as rtlRender } from '@testing-library/react-native'; 4 import { createStore } from 'redux'; 5 import { Provider } from 'react-redux'; 6 7 import { reducer } from '../src/store'; 8 9 function render( 10 ui, 11 { 12 initialState, 13 store = createStore(reducer, initialState), 14 ...renderOptions 15 } = {} 16 ) { 17 function Wrapper({ children }) { 18 return <Provider store={store}>{children}</Provider>; 19 } 20 return rtlRender(ui, { wrapper: Wrapper, ...renderOptions }); 21 } 22 23 // re-export everything 24 export * from '@testing-library/react-native'; 25 // override render method 26 export { render };