You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
i am a new comer for jest and working on a project with some feature to draw on a canvas element.
in my test, i found that it didn't work when i tried to expect on a call on the mocked canvas.ctx.fillText. let me explain the details as below.
`
//the render from '@testing-library/vue' to spin up the detectedObjects component with only a canvas element.
const { container } = render(detectedObjects);
const canv = container.querySelector('canvas');
const ctx = canv.getContext('2d');
advance(50); // after 50ms, the component will call ctx.fillText to draw some text on the canvas.
expect(ctx.fillText).toHaveBeenCalledTimes(1); // however it fails at this step always.
`
i can assure that the code in the component that calls fillText has been executed before the expect. when i experimented by adding "ctx.fillText('hello world!', 1, 2)" before the expect, the test passed.
can you help to check why my test case doesn't work? thanks a lot in advance for your help.
The text was updated successfully, but these errors were encountered:
Hi,
i am a new comer for jest and working on a project with some feature to draw on a canvas element.
in my test, i found that it didn't work when i tried to expect on a call on the mocked canvas.ctx.fillText. let me explain the details as below.
`
//the render from '@testing-library/vue' to spin up the detectedObjects component with only a canvas element.
const { container } = render(detectedObjects);
`
i can assure that the code in the component that calls fillText has been executed before the expect. when i experimented by adding "ctx.fillText('hello world!', 1, 2)" before the expect, the test passed.
can you help to check why my test case doesn't work? thanks a lot in advance for your help.
The text was updated successfully, but these errors were encountered: