forwardemail / forwardemail/superagent
Node version is used in JSDOM environment
Open
- Dominant language
- JavaScript
- Stars
- 16.6k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
I was trying to figure out why mocking XHR wasn't affecting superagent requests when running my unit tests with Jest. After much debugging it turns out the node version of superagent was getting used in my test environment instead of the browser version. JSDOM emulates the browser environment so it seems incorrect that the node version would get loaded here.
A workaround is to set jests's `moduleNameMapper` like this in your jest config file:
```js
moduleNameMapper: {
// use browser version of superagent
superagent: 'superagent/dist/superagent'
},
```
Contributor guide
Assessment
This issue has not been assessed yet.