Testing GraphQL React Components
Fernando Dingler
3613

I got a snapshot test of an apollo component to work with MockedProvider with something like this:

import React from 'react'
import renderer from 'react-test-renderer'
import { MockedProvider } from 'react-apollo/test-utils'
import Component from '../components/Component'
it('Component renders correctly', () => {
const tree = renderer(create(
<MockedProvider mocks={[]}>
<Component />
<MockedProvider>
).toJSON()
expect(tree).toMatchSnapshot();
})

The mocked provider takes a mocks prop with is an array of mocked data. Here is the comment that helped me: https://github.com/apollographql/apollo-test-utils/issues/30#issuecomment-318311066

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.