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

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

Mock HTTP fetch in sinon #1546

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

Comments

@maryam-saeidi
Copy link

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 : http://jsfiddle.net/maryam_saeidi/yredb06m/7/
  • Other libraries you are using:
    polyfill.js
    mocha.js
    chai.js
    mocha.css

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.)
http://jsfiddle.net/maryam_saeidi/yredb06m/7/

@fatso83 fatso83 closed this as completed Aug 30, 2017
@fatso83
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants