jest-canvas-mock
jest-canvas-mock copied to clipboard
getImageData returns undefined
This code line fails in Jest, because getImageData returns undefined:
const pixel = context.getImageData(1, 1, 1, 1).data;
Yep. You need to mock the return value.
Hi! Thanks ... ok I see I have to look how this entire mocking thing works (I'm new to Jest). Is there a list with methods that need to be mocked, that could be added to the README? I saw the short "Override default mock return value" about "toDataURL" and thought this is somewhat optional or special.
For the records: The root cause was the settings resetMocks: true
in my Jest config which causes to clear all default mocks created by jest-canvas-mock...
Ah yeah that will do it. Glad you found the issue.