Mike-Gibson / mock-apollo-client

Helps unit test components which use the Apollo Client.
MIT License
117 stars 15 forks source link

Mock multiple queries in one test #51

Closed froliceric0914 closed 1 year ago

froliceric0914 commented 1 year ago

The setRequestHandler can only be used once per test, but when are some senerios that more than 1 query are used in one component--they could be called in async fashion as well. Is there any plan to improve the feature to enable this request? Thank you!

Mike-Gibson commented 1 year ago

setRequestHandler can only be called once per unique query, yes. In scenarios where the same query may be executed multiple times (either with the same variables, or different variables), this behaviour can be controlled via the handler that's invoked (rather than adding multiple handlers for the same query).

A similar question has been asked in #10 . Could you please take a look and see if this addresses your issue? If your request is slightly different, let me know and we can see how it could be sorted.

Mike-Gibson commented 1 year ago

Hopefully you found a way to solve the problem. Please re-open if not.