Created
April 7, 2022 04:49
-
-
Save xiongemi/22b26063e57981ff08f481e80bba2005 to your computer and use it in GitHub Desktop.
mock redux store unit test for react native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
initialRootState, | |
RootState, | |
} from '@studio-ghibli-search-engine/store'; | |
import { render } from '@testing-library/react-native'; | |
import React from 'react'; | |
import { Provider } from 'react-redux'; | |
import configureStore, { MockStoreEnhanced } from 'redux-mock-store'; | |
import Film from './film'; | |
describe('Film', () => { | |
const mockStore = configureStore<RootState>([]); | |
let store: MockStoreEnhanced<RootState>; | |
beforeEach(() => { | |
store = mockStore(initialRootState); | |
store.dispatch = jest.fn(); | |
}); | |
it('should render successfully', () => { | |
const { container } = render( | |
<Provider store={store}> | |
<Film /> | |
</Provider> | |
); | |
expect(container).toBeTruthy(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment