Skip to content

Instantly share code, notes, and snippets.

@JakeDawkins
Created June 13, 2018 16:17
Show Gist options
  • Select an option

  • Save JakeDawkins/cb95885c0a1d98fd32162ff2a5409ae1 to your computer and use it in GitHub Desktop.

Select an option

Save JakeDawkins/cb95885c0a1d98fd32162ff2a5409ae1 to your computer and use it in GitHub Desktop.
// dog.test.js
import { MockedProvider } from 'react-apollo/test-utils';
// The component AND the query need to be exported
import { GET_DOG_QUERY, Dog } from './dog';
const mocks = [
{
request: {
query: GET_DOG_QUERY,
variables: {
name: 'Buck',
},
},
result: {
data: {
dog: { id: '1', name: 'Buck', breed: 'bulldog' },
},
},
},
];
it('renders without error', () => {
renderer.create(
<MockedProvider mocks={mocks} addTypename={false}>
<Dog name="Buck" />
</MockedProvider>,
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment