mercredi 26 juin 2019

Mock Bing Maps API with Jest in React.js

In my Jest test I need to generate a Bing Maps Push Pin like this:

it('...', () => {
  var e = new window.Microsoft.Maps.Pushpin({ "latitude": 56.000, "longitude": 46.000 }, {});
  /* do stuff */
  expect(e.getColor()).toEqual('#ffd633');
})

But while I'm running the test I get the error:

TypeError: Cannot read property 'Maps' of undefined

Does someone know how to mock that Bing Maps API Microsoft interfaces with Jest in React?

Aucun commentaire:

Enregistrer un commentaire