Ask questionsUsing MockedProvider results in error "No more mocked responses for the query: ..."

I'm not sure why this happens, it seems I need to set up some MockedResponses but I don't know how to do that. When I console.log _this.mockedResponsesByKey and key in MockNetworkInterface.prototype.query it looks like the keys don't match because one is a string and the other is an object. I could be reading this wrong though.

Steps to Reproduce

Mount a MockedProvider using enzyme.

const query = addTypenameToDocument(myQuery);

const mounted = mount(
	<MockedProvider mocks={[
			request: { query, variables },
			result: { data: mockedData },
		<ConnectedComponent { ... routerParams } store={store} />

Buggy Behavior

The component receives No more mocked responses for the query: ... in

Expected Behavior

Should not throw an error


  • apollo-client@1.0.1
  • react-apollo@0.9.0

Answer questions FernandoBasso

If you refetch the query twice you will need three identical mock requests and responses.

This part of the answer was especially important for me (in my case it is a fetchMore). I don't think it is mentioned the docs.


Related questions

useLazyQuery execution function should return a promise hot 2
Fresh new install gives unmet peer dependencies warnings with yarn hot 2
Upgrading to 3.0.1 gives the following: Invariant violation: Could not find "client" hot 2
"Invalid hook call." error while using `Query` or `useQuery` with react-apollo 3 hot 1
currentObservable.query.fetchMore is not a function - react-apollo hot 1
MockedProvider can't mock queries with client directives hot 1
Attempted import error: &#39;compose&#39; is not exported from &#39;react-apollo&#39; hot 1
Query result proposal: use actual data or {} to enable easier destructuring hot 1
currentObservable.query.getCurrentResult is not a function hot 1
Apollo MockedProvider with client directives hot 1
Could not find "client" in the context of ApolloConsumer when using react-apollo 2.5.3 with MockedProvider hot 1
useQuery infinite loop re-rendering - react-apollo hot 1
watchQuery is not a function - react-apollo hot 1
MockedProvider does not return data when fetchPolicy is set to &#34;cache-and-network&#34; - react-apollo hot 1
MockProvider is not reporting results.errors hot 1
Github User Rank List