Closed jci-aws closed 4 months ago
Hey @jci-aws 👋
It looks like you're configuring variableMatcher
on the request
key, but this is not correct. This should be placed as a top-level key in the mock as specified in the documentation. If I move the variableMatcher
there, I see that the warning goes away:
const mocks = [
{
request: {
query: GET_DOG_QUERY,
},
variableMatcher: () => true,
result: {
data: {
dog: { id: "1", name: "Buck", breed: "bulldog" },
},
},
},
];
It looks like your test passes in the sandbox because you're only checking the loading
state of the component, but don't check against data
or error
. If I log the loading
, data
and error
values of your Dog
component used for the test, I see that error
is also set to the same message as the warning you're seeing in the console once its finished loading.
Hope this helps!
Thought I was going crazy. Thanks!
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
No problem! Sometimes an outside perspective is all thats needed 😆. Glad its working for you! Have a great day.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.
Issue Description
When testing with
MockedProvider
, I have provided avariableMatcher
to one of myMockedResponse
s. When running the test, the tests still pass but there is a console warning about the queries not matching:Since this test query is being matched through
variableMatcher
, I would not expect this warning to appear.Link to Reproduction
https://codesandbox.io/s/sharp-butterfly-fkxn55?file=/src/dog.test.js:258-292
Reproduction Steps
Run tests in CodeSandbox, see warning message in console tab.
@apollo/client
version3.10.8