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

bug: simple expect().toReturnWith() works incorrectly #6017

Closed
iuioiua opened this issue Sep 19, 2024 · 2 comments
Closed

bug: simple expect().toReturnWith() works incorrectly #6017

iuioiua opened this issue Sep 19, 2024 · 2 comments

Comments

@iuioiua
Copy link
Contributor

iuioiua commented Sep 19, 2024

The following fails when it should pass:

import { expect, fn } from "@std/expect";

const mock = fn(() => 42);

expect(mock).toHaveReturnedWith(42);
@iuioiua iuioiua changed the title bug: simple expect().not.toReturnWith() works incorrectly bug: simple expect().toReturnWith() works incorrectly Sep 19, 2024
@kt3k
Copy link
Member

kt3k commented Sep 20, 2024

It is expected to fail because mock is not called. You need to call mock to pass that check:

import { expect, fn } from "@std/expect";
const mock = fn(() => 42);
mock();
expect(mock).toHaveReturnedWith(42);

@iuioiua
Copy link
Contributor Author

iuioiua commented Sep 23, 2024

Yeah, I realised my understanding of mock() was wrong. Thanks!

@iuioiua iuioiua closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2024
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

3 participants
@kt3k @iuioiua and others