Posts
Members
Info
Mutation not updating graphql cache when using MockedProvider
In a non-testing environment for my React Apollo apps, when a mutation returns with some new data, the graphql cache will be updated, which then causes component to re-render and display the new data. But I've never been able to replicate that when testing using MockedProvider.…
0
0
How to test useLazyQuery?
I love the documentation about testing react components with useQuery and useMutation. (https://www.apollographql.com/docs/react/development-testing/testing/) But I struggle when testing the useLazyQuery-hook. …
2
8
MockedProvider mocks are impossible to maintain
I'm really thankful for Apollo and the MockedProvider utility. Both great tools. The issue I'm currently having though is that I'm finding it way too time consuming trying to maintain my mocks. How can I debug the MockedProvider constantly returning nothing? It has been taking…
1
0
Deleted·32d# Testing
apollo-datasource-rest + Typescript + Jest
I am setting up a new project using Apollo, TypeScript & Jest and I'm running into some difficulty testing my datasources that extent RESTDataSource. Jest will not mock the class to be extended & much of the advice I'm coming across recommends switching to composition over…
2
4
MockedProvider error Could not find "client"
Updated to @apollo/client/testing from @apollo/react-testing. Changed import { MockedProvider } from '@apollo/client/testing'; Still we have an error while running jest tests "Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root…
0
0
Mutation doesn't resolve in Jest test
Getting the following error: Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout. The console.log('created log') never runs. I've been stuck on this for two days, so any help would be hugely appreciated! The test: …
0
0
·133d# Testing
Fragment is not working with MockedProvider
When I use a fragment in my code, it works in a browser environment, but it fails in the tests when using MockedProvider from Apollo. If my Fragment looks like this: My fragment looks like this: …
1
5
fields contained in fragment are not being returned from mocks
Intended outcome: I'm trying to write some tests that involve some queries that contains fragments in them. The fields in the fragments get retrieved just fine in the local environment, but when I try to run it through jest, I get back all the fields except for the ones in the…
1
1
MockedProvider never returns any data
[email protected] with testing-library/[email protected] i am using useLazyQuery and in test mode it never resolves. loading is always true and data always undefined. My mock query and variables match exactly the query and variables used in the component i am testing, yet i still get no…
0
1
·149d# Testing
withApollo `TypeError: Cannot read property 'query' of undefined`
libraries used Component setup Unit Test …
1
2