First line of http-io.js, code under test: import fetch, { RequestInit } from 'node-fetch';
Now, when I debug and look at fetch I see something odd:
right after the import in http-io.js fetch is a mock
when the test actually calls the function in http-io.js fetch is not a mock
I gotta think this is something going on with node-fetch <-> jest-fetch-mock since this isn't happening in the other project that uses "browser" fetch.
Got 2 projects, one is a backend and the other frontend. I implemented jest-fetch-mock in the frontend first with no issues.
Now I'm implementing in the backend and it just won't actually mock fetch when the code I'm testing gets called.
Versions: node-fetch: 2.6.1 jest: 27.1.0 node: 14.17.6 jest-fetch-mock: 3.0.3
jest.config.js:
.jest/setupFetchMocking.js:
require('jest-fetch-mock').enableMocks()
http-io.test.js, first 2 lines:
Failing test:
First line of http-io.js, code under test:
import fetch, { RequestInit } from 'node-fetch';
Now, when I debug and look at
fetch
I see something odd:fetch
is a mockfetch
is not a mockI gotta think this is something going on with
node-fetch
<->jest-fetch-mock
since this isn't happening in the other project that uses "browser"fetch
.