-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Added feature: res.networkError() mocks a network error #253
Added feature: res.networkError() mocks a network error #253
Conversation
Hey. I've looked into your implementation and it looks good! What happens now is that whenever you use I believe we need to find a way to cancel a pending request (or respond with a network error from the worker/node), so it doesn't get executed. |
I have some new information on how to properly handle an exception thrown within a request handler. Will update soon, it's a change to |
Hey. I've rebased your feature branch against the latest |
Nice! I'm very busy this weekend but I'll try to take a look later. |
I've updated the branch, and added the logic that treats the exception thrown in It's possible to emulate a network error on the Service Worker side by rejecting the pending request promise. Once done, it produces the very same errors as a regular network error. The only thing I couldn't get to is asserting the custom network error message in the browser test. Somehow both fetch rejection and captured console errors don't have it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome. I'm excited to ship res.networkError
feature in the next release.
Superb job, @jensmeindertsma! Thank you and welcome to contributors 🎉
I added the feature so you can now use
res.networkError()
inside a request handler to mock a network request. This is useful because this will trigger the Fetch API to throw an error, and you can thus test whether your function handles this error correctly.GitHub