-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-utils.js
27 lines (25 loc) · 877 Bytes
/
test-utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import React from 'react'
import { render } from '@testing-library/react'
import { Provider } from 'react-redux'
import { configureStore } from '@reduxjs/toolkit'
import rootReducer from './src/redux/reducers'
// Create a custom render function that includes the Redux store and any other provider components.
function customRender(
ui,
{
initialState,
store = configureStore({
reducer: rootReducer,
preloadedState: initialState,
}),
...renderOptions
} = {}
) {
function Wrapper({ children }) {
return <Provider store={store}>{children}</Provider>
}
return render(ui, { wrapper: Wrapper, ...renderOptions })
}
// Export your custom render function for use in your tests.
export * from '@testing-library/react' // Re-export all react-testing-library functions
export { customRender as render } // Export your custom render function