Skip to content
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

Returns rejected promise promise when config.greed = bad #40

Closed
danny-andrews opened this issue Dec 4, 2015 · 2 comments
Closed

Returns rejected promise promise when config.greed = bad #40

danny-andrews opened this issue Dec 4, 2015 · 2 comments

Comments

@danny-andrews
Copy link
Contributor

This library rejects the promise when you set promise config.greed = bad (ref), but the fetch specification states:

The Promise returned from fetch() won't reject on HTTP error status even if the response is a HTTP 404 or 500. Instead, it will resolve normally, and it will only reject on network failure, or if anything prevented the request from completing.

https://github.com/github/fetch#caveats
We should just resolve as normal here.

@wheresrhys
Copy link
Owner

To be honest, I'm not sure how useful being able to configure bad responses is. greed: 'good' is a feature I use from time to time, and it's also useful to be able to let unmatched requests pass through to native fetch. greed: 'bad' is only there for completeness really. I don't see it as running contrary to the fetch spec though: fetch 'will only reject on network failure, or if anything prevented the request from completing.' So greed: bad kinda equates to the worst case scenario for a fetch request.

I could add the ability to configure the behaviour more precisely e.g greed: {status code}, and will leave this issue open to see if anyone else wants the feature. Personally I think if the developer cares that much about status codes returned by the fetch calls in their test, then they should probably be mocking those calls individually or with some predefined routes.

What are you using/planning on using greed: bad for?

@danny-andrews
Copy link
Contributor Author

I decided against using fetch, I was having too much friction trying to mock it out in tests. You make a good point about the network failure, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants