Created
April 25, 2022 10:41
-
-
Save petrosDemetrakopoulos/e7c87edc177bb03bfb79a7396d223277 to your computer and use it in GitHub Desktop.
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 renderer, { act } from 'react-test-renderer' | |
| import App from '../App' | |
| const mockData = { | |
| data: [ | |
| { name: 'a fake name', surname: 'fake surname', email: '[email protected]' }, | |
| { | |
| name: 'a fake name 2', | |
| surname: 'fake surname 2', | |
| email: '[email protected]', | |
| }, | |
| ], | |
| } | |
| jest.mock('axios', () => { | |
| return { | |
| get: jest.fn().mockImplementationOnce(() => Promise.resolve(mockData)), | |
| } | |
| }) | |
| describe('App component', () => { | |
| it('it works', async () => { | |
| let tree | |
| await act(async () => { | |
| tree = renderer.create(<App />) | |
| }) | |
| expect(tree.toJSON()).toMatchSnapshot() | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment