No more mocked responses for the query

I have a component that is working fine. However, I’m getting this issue whenever I try to run a test using <MockedProvider>:

No more mocked responses for the query:

Followed by the query, then below it this:

    Expected variables: {"id":&lt;undefined&gt;}

    Failed to match 1 mock for this query, which had the following variables:
      {"id":"123"}

I tried to supply it with the “expected variables” but that, of course, makes my query fail, and so the test fails anyway.

I’ve read previously that this issue can be caused when the data doesn’t match the query, however I console.logged the data, transformed it to a JavaScript object and have used that in my test.

Does anyone have an understanding of what’s happening here?

@endymion1818 this usually happens when your component under test is rendering more times than you realize, and you aren’t providing enough mock responses. I’d recommend watching your renders to see if that’s happening. If not, post some of your test + component code here and we’ll take a closer look.

1 Like

Thanks, very helpful. It turns out it I was passing an incorrect variable. But I’m glad you said this.

1 Like

Solved.