Created
October 2, 2019 20:54
-
-
Save renanmav/9f91167181546f40cf5a9bd924323a22 to your computer and use it in GitHub Desktop.
Simple test of relay component using rtl and relay-test-utils
This file contains 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 rtl from 'react-test-renderer' | |
import { createMockEnvironment, MockPayloadGenerator } from 'relay-test-utils' | |
import MyRelayComponent from './MyRelayComponent' | |
test('Data Render', () => { | |
const environment = createMockEnvironment() | |
const renderer = rtl.create(<MyRelayComponent environment={environment} />) | |
environment.mock.resolveMostRecentOperation(operation => MockPayloadGenerator.generate(operation)) | |
expect(renderer.root.find(node => node.props['data-testid'] === 'myButton')).toBeDefined() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment