MockedProvider support?
See original GitHub issuereact-apollo
exports react-apollo/test-utils#MockedProvider
, I can’t find anything similar for react-apollo-hooks.
I could use
jest.mock('react-apollo-hooks', () => ({
__esModule: true,
useQuery: () => ({ data: mockedData, loading: false }),
})
Is this supported or is jest.mock the suggested approach?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Testing React components - Apollo GraphQL Docs
The MockedProvider component enables you to define mock responses for individual queries that are executed in your test. This means your test doesn't...
Read more >MockedProvider can't mock queries with client directives #3316
When using a MockedProvider and a query with client directives, the client directives should resolve. Query example: query Cats { cats { name...
Read more >Debugging Apollo GraphQL MockedProvider - Swarmia
This blog post is here to help! ... Let's go through five practical tips to make debugging Apollo MockedProvider more enjoyable.
Read more >The Do's and Don'ts of Testing Apollo in React - Adam Hannigan
By mocking requests at the service worker level you enable your ... The Apollo MockedProvider outlines that “Your test must execute an ...
Read more >Testing React components - Apollo GraphQL Docs
... functionality with Apollo Client itself, so they will be supported long-term. ... dog.test.js import { MockedProvider } from '@apollo/client/testing'; ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the reply!
Would it make sense to expose a pre-built
MockedProvider
that internally makes use ofapollo-link-mock
andapollo-cache-inmemory
so that this library exposes a similar API surface asreact-apollo
?you could also use above’s
<MockedHooksProvider />
instead of react-apollo’s<MockedProvider />
as above. Then use<MockedHooksProvider />
in the same way as<MockedProvider />
: