-
Notifications
You must be signed in to change notification settings - Fork 158
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
Expose a way to passthrough after the request is found to be unhandled #238
Expose a way to passthrough after the request is found to be unhandled #238
Conversation
b38bf86
to
3b54218
Compare
I created this PR a long time ago with the full intent to finish off that checklist above. However, I understand that new features like this may not be desirable in your project, and now that I am back to working on a project that depends on my fork, I'd love to finish this off if it is something that belongs in Pretender. I'd be happy to finish this PR (and also add proper TS typings for the new feature) if someone who maintains this project would let me know if the functionality is desired. I found it immensely helpful to be able to call Any thoughts, @bantic, @mike-north, @trek, or @xg-wang? |
9984ed2
to
fd6b942
Compare
@xg-wang I went ahead and did this. Tests pass. I hope this feature is something you agree with. I have found it immensely useful. |
Being able to decide whether to passthrough a request at runtime is super useful & actually something we added to Mirage. I'm in favor! |
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.
Yeah I think this feature is great, and your use case makes a lot of sense. Sorry for the delay!
I am happy to make the requested changes. I don’t blame you for not commenting sooner. My original example left a little something to be desired (like how is it useful?!). Thanks for having a look. I’ll get around to those changes either tonight or within a few days. |
Anytime `send` is called, the arguments are saved in the fake xhr instance. They can subsequently be used in the `.passthrough()` method. This allows us to pass through a request after it has been caught by Pretender.
fd6b942
to
0800554
Compare
I should note that in addition to the adding a test, I altered the readme to more accurately reflect what happens when the user calls the new method. |
This PR aims to allow a request to be passed-through in the
unhandledRequests
hook.Totally fine to say that you don't want this feature. I am adding it for me, but since it was simple, I figured add PR you here.
This allows you to actually pass certain unhandled requests through at runtime if you so choose. Sam Selikoff offered this as an example of a feature this unlocks (better than my original example). Currently, you can't really simply declare multiple multiple domains as a passthrough. You'd need something like:
This feature addition allows you to handle all of them with any runtime check you'd like to implement:
.passthrough()
method to the FakeRequest