Open TigerWolf opened 2 years ago
Did you also upgrade to "node-fetch" 3.x or was this only a change in Jest versions?
I'm also seeing fetch not being mocked in Jest 27 but Node 14.
When I debug and look at fetch
global right after imports are done, it's a mock. But then when my functions are running it's no longer a mock.
Updating from node-fetch@2.x
to 3.x
didn't fix it
Concerned about this though:
✗ npm ls | grep fetch
├─┬ @types/node-fetch@2.5.12
├─┬ jest-fetch-mock@3.0.3
│ ├─┬ cross-fetch@3.1.4
│ │ └── node-fetch@2.6.1
├─┬ node-fetch@3.0.0
│ └─┬ fetch-blob@3.1.2
Two versions of node-fetch, one is required by jest-fetch-mock
?
npm find-dupes
may help with multiple node-fetch
versions.
Hmm, for me it's very different:
ReferenceError: Response is not defined
That's with Node Version: v17.5.0
If i remember correctly, i had the same issue on v16 (This been blocking me for a while in the upgrade)
Is this library still being maintained?
On node 17 it fails with --experimental-fetch
flag as well as it fails on v18.
Tried assigning globalThis.Response
myself using cross-fetch and node-fetch without luck.
Is this library still being maintained?
Would be nice if this gets resolved as this blocking a lot of people from upgrading
After upgrading to NodeJS 16 I got some wierd issues in my tests that used jest-fetch-mock.
With this simple test:
If I run with Jest 26:
With Jest 27 I get:
Is this an issue with something I am doing that has changed in Jest or is jest-fetch-mock not working correctly?
It looks like fetch isn't being mocked and is returning an error which is failing the test (I could be wrong).
The code it is testing is quite simple: