Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can it be use with uve? #80

Open
bin787 opened this issue Mar 12, 2021 · 0 comments
Open

can it be use with uve? #80

bin787 opened this issue Mar 12, 2021 · 0 comments

Comments

@bin787
Copy link

bin787 commented Mar 12, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant