mercredi 4 janvier 2017

testing fetch with mocha and chia

I have the following example test:

import { assert } from 'chai'

function starWarsMovies () {
  fetch('http://ift.tt/1AEc3FK')
    .then((res) => {
         return res.json()
     })
     .then((res) => res.count)
}

describe('Get star war movies', () => {
  it('should get 7', () =>{
    assert.equal(starWarsMovies(), 7)
  })
})

But I getting

ReferenceError: fetch is not defined

What do I have to use in order to test a fetch request.

Aucun commentaire:

Enregistrer un commentaire