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.