-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Provide a way to simulate network delay in mock responses #56
Comments
Option 1 should be pretty easy. Here, we can check if |
+1 |
can this also be implemented by using the keepNonSubscriptionConnectionsOpen? I cannot seem to get it to work with something like:
Also |
@danielvanmil I don't think |
@niieani : thanks for the answer, but I still don't understand it. I notices the keepNonSubscriptionConnectionsOpen option and thought I could use this to delay a query or mutation response just like I can respond to subscriptions. What is the use case of keepNonSubscriptionConnectionsOpen and can it be used to delay a response? (otherwise I don't understand what it can be used for? Is it possible to provide a nice exampe, test or doc? Thanks and keep up the great work! |
Use Case:
I'd like to be able to write a test to simulate an async/delayed response from the GraphQL server. This would be similar to enabling "network throttling" in Dev Tools to test what happens when it takes a while for the server to respond, and would be useful for testing things like race conditions that pop up when certain queries finish before others.
Implementation Options
Promise
from the ResultFn type. Laika waits for the Promise to resolve before returning the mocked result.delay
in the mock configuration, and Laika automatically handles making it async.I think both options would be useful, honestly. The first one would be great for unit tests, so you could manually resolve the promise whenever you were ready vs. specifying an arbitrary amount of time. But, the second one would be nice for less boilerplate code when all you want is to make your test behave a little more like a real server.
The text was updated successfully, but these errors were encountered: