-
Notifications
You must be signed in to change notification settings - Fork 285
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
Getting referenceerror: self is not defined when running mocha tests in command line as soon as I attempt to use isomorphic-fetch #59
Comments
This issue also causes React Native to crash. The problem is if GitHub's library is loaded without a browser environment, |
My workaround right now is to use webpack's providerPlugin to load fetch for dev, deploy, but not test (separate webpack.config file for each env). That means of course that I cannot call actual fetch at all, but have to stub it via a mocking framework. This is all right for unit testing, but won't work for integration testing. Also disallows me from using sinon's fake server functionality (since that would require an actual fetch call). |
Having this same issue... Should we exclude something from the build (webpack |
I got this fixed within GitHub's code (JakeChampion/fetch#253) But my PR on this repo also needs to be merged to resolve this entirely: #63 |
Much obliged @billinghamj ! Just wait for the merge I guess |
Yeah, I'm waiting for the merge as well. 👍 Since it is a quick fix I made the changes directly in the file on |
What is the status of this merge? |
@matthew-andrews seems to be uninterested in resolving this. As such, @lucasfeliciano created "fetch-everywhere" instead which is designed to work in every circumstance - https://github.com/lucasfeliciano/fetch-everywhere |
@billinghamj Yes, just testing it :) Thanks :D |
Same |
@matthew-andrews: Also experiencing this, is there no solid solution yet, or roadmap for this to be merged. The community seems to be drifting away from this lib in favour of fetch-everywhere simply due to this issue. |
@andrewmclagan Indeed :) |
I'm still getting this issue my solution: lucasfeliciano/fetch-everywhere#7 |
i had this error working with chai/mocha test. then import it at the top of my test: works for me. |
Another solution is to make sure node has a |
So I wanted to use this, and I have a SPA client only app using webpack, npm, es6. The moment I add this line in:
import fetch from 'isomorphic-fetch';
The moment I have this line, my mocha tests crash with -- referenceerror: self is not defined -- error. Mocha browser runs fine, and I can perform a fetch correctly.
I can't get command line mocha test fixed. How do I fix this? I don't have this issue when I import any other libraries, including React-DOM which is definitely dependent on a DOM.
The text was updated successfully, but these errors were encountered: