TypeError: Cannot read property ‘setTransform’ of null when using Openlayers and Jest + Enzyme [closed]

The issue here is that jsdom browser doesn’t support canvas API so in order to fix this you can install this dev dependency jest-canvas-mock to add canvas api to jsdom window. Here is a few steps:


yarn add -D jest-canvas-mock

// or npm

npm i -D jest-canvas-mock

Add this package as your setupFiles of jest:

  setupFiles: ['jest-canvas-mock']

That’s it!

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top