node-fetch-cjs
node-fetch-cjs copied to clipboard
fetch unstubable
I tried my code
let stubFetch;
const fetch = require("node-fetch-commonjs");
stubFetch = sinon.stub(fetch, "default");
stubFetch.returns(Promise.resolve(new Response(undefined, { status: 200 })));
stubFetch.restore();
it doesn't work.
how to stub your code?
I haven't worked with sinon yet, but if you get an error or something I think that might be helpful.
After looking at the documentation of sinonjs and the code of node-fetch rq I have two things in mind that could be tried:
- use
sinon.stub(fetch, "fetch");
instead - use
sinon.stub(fetch);
instead