3

I have some components I want to test which perform multiple graphql queries. When using

environment.mock.resolveMostRecentOperation

I am able to treat those in order. However that is really bothersome to do on every test.

I have been trying to use environment.mock.queueOperationResolver so that I can provide a mock resolver and I was expecting this queue resolver to be triggered every time there was a new query added to the queue. However, the result I am getting is that the queueOperationResolver handles the first query automatically and fails (seems to not get called at all) to handle any subsequent query.

Is that expected behavior or am I doing something wrong?

In the examples on the relay docs, I only found examples handling one query at a time, so I wasn't able to really validate that expectation.

 environment.mock.queueOperationResolver((operation) => {
 return solveRelayQuery(operation, testCurrencyCode, queryHandler);
 });
 const user = userEvent.setup();
 await act<RenderResult>(async () => {
 return render(
 <RelayEnvironmentProvider environment={environment}>
 <MemoryRouter>
 <MyTestComponent />
 </MemoryRouter>
 </RelayEnvironmentProvider>
 );
 });

This snippet is how I am trying to set it up. The first query my component does is being properly handled by the test, but it always fails while expecting the second to be processed.

asked Nov 18, 2024 at 12:57

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.