Created
December 28, 2022 11:35
-
-
Save CodeNinja47/1408a369ed8d35ca8c8cc9706d8e8126 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 { screen, waitFor } from '@testing-library/react'; | |
| import { | |
| createMockEnvironment, | |
| MockPayloadGenerator, | |
| } from 'relay-test-utils'; | |
| import ReactTestRenderer from 'react-test-renderer'; | |
| import { customRender } from './testUtils/test-utils'; | |
| import Testing from './Testing'; | |
| test('Mocking GraphQL queries', async () => { | |
| const environment = createMockEnvironment(); | |
| customRender( | |
| <Testing environment={environment} /> | |
| ); | |
| const operations = environment.mock.getAllOperations(); | |
| ReactTestRenderer.act(() => { | |
| operations.forEach(operation => { | |
| environment.mock.resolve( | |
| operation, | |
| MockPayloadGenerator.generate(operation, { | |
| String() { | |
| return "Sample"; | |
| }, | |
| ID() { | |
| return '12' | |
| } | |
| }) | |
| ); | |
| }); | |
| }); | |
| await waitFor(() => screen.getByText('Sample'), { timeout: 2000 }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment