Nock doesn't work with the latest version of jsdom
See original GitHub issueJsdom has updated the way they implement XMLHttpRequest
in version 8.2.0. My test suite sets up jsdom for some (unrelated to nock) UI tests. With version 8.2.0 of jsdom installed nock fails to mock requests (they actually hit the network). Version 8.1.0 works fine. Tested with version 7.7.2 of nock.
cc @domenic, @nicolashenry from jsdom.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
React API test with Nock failing with "Error - node.js
If you're using jest + react, your jest config sets the testEnviromnent to jsdom . But nock requires a node environment to mock...
Read more >Jest 27: New Defaults for Jest, 2021 edition
In the Jest 26 blog post about a year ago, we announced that after two major releases with few breaking changes, Jest 27...
Read more >Stop mocking fetch - Kent C. Dodds
But, one issue with this is because you're mocking out the client , how do you really know the client is being used...
Read more >nock: disallowed net connect - You.com | The search engine you ...
probot/probotProbot (Nock) Unit Tests Not Working with Github Enterprise#928 ... Probot version(s): 7.5.3; Node/npm version: node 8.12 npm 6.4.1 ...
Read more >When JSDOM for testing UI is not enough - Level Up Coding
JSDOM is a pure javascript implementation of the DOM so it's not even designed ... With Playwright you can run the last version...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kwhitaker for my use case I use a url (
front.dev.porch.com
) that redirects to localhost via my hosts file. So my jsdom call is:Then hitting
http://front.dev.porch.com:9339/foo/service/route
worked within my tests. I did need to usenock.recorder.rec()
to get the EXACT nock calls necessary for intercepting to work, just FYI.This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!