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:
Install:
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.