Getting referenceerror: self is not defined when running mocha tests in command line as soon as I attempt to use isomorphic-fetch

Author: ericlau-solidCreated Dec 29, 2015Updated Sep 17, 2021

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.

Source: matthew-andrews/isomorphic-fetch