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

gaxios fails with jest #87

Closed
adriano-di-giovanni opened this issue Apr 26, 2019 · 3 comments · Fixed by #90
Closed

gaxios fails with jest #87

adriano-di-giovanni opened this issue Apr 26, 2019 · 3 comments · Fixed by #90
Assignees
Labels
released 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@adriano-di-giovanni
Copy link

The default test environment that Jest uses for testing is a browser-like one through jsdom.

The browser-like environment makes your following line of code fail:

const fetch = isBrowser() ? window.fetch : nodeFetch;

because typeof window !== 'undefined' in isBrowser() evaluates to true but window.fetch is undefined.

Maybe, you can directly check against the existence of window.fetch instead of relying on isBrowser.

If you agree, I can send you a PR to replace each and every check against isBrowser with a feature-detection check.

@adriano-di-giovanni
Copy link
Author

I'd like to add that it is possible to change the test environment that Jest uses for testing but I think that a feature-detection style improves the quality of the check your code relies on.

@JustinBeckwith JustinBeckwith added the triage me I really want to be triaged. label Apr 26, 2019
@JustinBeckwith
Copy link
Contributor

Greetings @adriano-di-giovanni, and thanks for the issue! Something like what you suggested sounds reasonable. I'd love a PR!

@JustinBeckwith
Copy link
Contributor

🎉 This issue has been resolved in version 2.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants