mardi 28 juin 2016

How to test code that is using whatwg-fetch with mocha?

I'm using http://ift.tt/11gdJb1 in my app, which works fine but I would like to test my code with Mocha.

This does not work out of the box. I'm getting:

1) testApi.js Test api error handling:
 ReferenceError: fetch is not defined
  at callApi (callApi.js:10:10)
  at Context.<anonymous> (testApi.js:8:40)

Because well, fetch is not defined. When I build for the browser fetch is exposed by webpack.

I've tried using http://ift.tt/18q0Hew but the api is slightly different and wants full url's instead of relative paths for example.

Is there a solution to this problem?

Aucun commentaire:

Enregistrer un commentaire