React-map-gl: Unit testing

Created on 26 Apr 2017  路  4Comments  路  Source: visgl/react-map-gl

Anyone else unable to run their unit tests on and receive this error?

TypeError: window.URL.createObjectURL is not a function

  at Object.193.../../source/worker (node_modules/react-mapbox-gl/node_modules/mapbox-gl/dist/mapbox-gl.js:396:100)
  at s (node_modules/react-mapbox-gl/node_modules/mapbox-gl/dist/mapbox-gl.js:1:711)

Most helpful comment

It's been a while, but here's the snippet of code I used to mock the mapbox-gl library

jest.mock('mapbox-gl/dist/mapbox-gl', () => ({
Map: () => ({})
}));

All 4 comments

@jenyeeiam sorry for the late response here. Was this on master? Which version of Node were you using?

No worries I resolved my problem, I found a way to mock the mapbox-gl library in my tests. Thanks anyways!

@jenyeeiam Can you share your code?

It's been a while, but here's the snippet of code I used to mock the mapbox-gl library

jest.mock('mapbox-gl/dist/mapbox-gl', () => ({
Map: () => ({})
}));

Was this page helpful?
0 / 5 - 0 ratings