Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch unstubable #4

Open
tistisman opened this issue Oct 18, 2022 · 1 comment
Open

fetch unstubable #4

tistisman opened this issue Oct 18, 2022 · 1 comment
Labels
question Further information is requested

Comments

@tistisman
Copy link

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?

@Wissididom
Copy link

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

@alex-kinokon alex-kinokon added the question Further information is requested label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants