-
Notifications
You must be signed in to change notification settings - Fork 656
std/expect: add spyOn
function
#6449
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
Comments
I'll see if I can make a PR on this. Probably next week. |
There is already mocks/spying in the import { expect } from "@std/expect";
import { stub } from "@std/testing/mock";
Deno.test(() => {
using logSpy = stub(console, "log");
console.log("hello");
expect(logSpy).toHaveBeenCalledTimes(1);
}); This does not work currently, since import { expect } from "@std/expect";
import { stub } from "@std/testing/mock";
Deno.test(() => {
using logSpy = stub(console, "log", fn(() => {}) as any);
console.log("hello");
expect(logSpy.fake).toHaveBeenCalledTimes(1);
});
It would be great if |
Hey @csvn I think that is a given. Unfortunately, whenever I think I have some free time I get drowned in some client work. I would implement this such that it fits into the current architecture. |
My comment was mostly because the issue title was not clear whether this was about adding something new or re-exporting/wrapping |
So the idea of this issue is to implement something like: import { expect } from "@std/expect";
import { spyOn } from "@std/expect/unstable-spy-on";
const spy = spyOn(console, "log");
console.log("hello");
expect(spy).toHaveBeenCalledWith("hello"); |
https://jestjs.io/docs/jest-object#jestspyonobject-methodname
The text was updated successfully, but these errors were encountered: