Replies: 2 comments 2 replies
-
It looks like Bun doesn’t support |
Beta Was this translation helpful? Give feedback.
0 replies
-
They have implented it in new bun versions according to the ticket #5394 import { expect, test, mock } from "bun:test";
import { main, main2 } from "./module";
test("before", async () => {
expect(main()).toBe(1);
expect(main2()).toBe(2);
});
test("after", async () => {
const mockDependency = () => "mocked";
mock.module("./module.ts", () => ({ main: mockDependency }));
expect(main()).toBe("mocked");
expect(main2()).toBe(2);
}); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey folks.
I was considering migrating our company's unit test to use bun to gain some performance but then I didn't find a way of mocking like
vi.mock('module-name', ()=>{...}
.I thought about importing the module and using
spyOn
but this would drastically change my current setup.Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions