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

Mock HTTP fetch in sinon #1546

maryam-saeidi opened this Issue Aug 30, 2017 · 1 comment


None yet
2 participants
Copy link

maryam-saeidi commented Aug 30, 2017

I am trying to mock HTTP fetch in jsfiddle. I am not sure what I do wrong that makes the result not to be equal to the mock one.

  • Sinon version : 3.2.1
  • Environment : chrome (Version 62.0.3198.0 (Official Build) dev (64-bit))
  • Example URL :
  • Other libraries you are using:

What did you expect to happen?
I want to mock the HTTP fetch function.

What actually happens
It seems it doesn't mock the fetch function.

How to reproduce
Here is my sample code: (You can see the logs in the browser console.)

@fatso83 fatso83 closed this Aug 30, 2017


This comment has been minimized.

Copy link

fatso83 commented Aug 30, 2017

Fetch is a different API from XHR. The underlying library of the XHR stubbing, nise, only supports XHR (and so does Sinon). You can check out sinonjs/nise#7 for some tips on how to accomplish stubbing the fetch library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.