Skip to content

Instantly share code, notes, and snippets.

@renanmav
Created October 2, 2019 20:54
Show Gist options
  • Save renanmav/9f91167181546f40cf5a9bd924323a22 to your computer and use it in GitHub Desktop.
Save renanmav/9f91167181546f40cf5a9bd924323a22 to your computer and use it in GitHub Desktop.
Simple test of relay component using rtl and relay-test-utils
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