What version of Bun is running?
1.0.3+25e69c71e70ac8a0a88f9cf15b4057bd7b2a633a
What platform is your computer?
Linux 5.15.0-83-generic x86_64 x86_64
What steps can reproduce the bug?
- Create a file
MyModule.ts
- Export a class
MyClass from the module with following structure:
export class MyClass {
myMethod() {
return 'Hello';
}
}
- Create a file
MyModule.test.ts
- Write a test that tests the myMethod
test('myMethod return value', () => {
const value = new MyClass().myMethod();
expect(value).toEqual('Hello');
})
- Create another file
OtherModule.test.ts
- Mock / spyOn the myMethod.
spyOn(MyClass.prototype, 'myMethod').mockImplementation(() => 'Hola');
- The
myMethod return value test starts failing like this:
error: expect(received).toEqual(expected)
Expected: "Hello"
Received: "Hola"
What is the expected behavior?
The mocks / spyOns should be contained within individual test suites.
What do you see instead?
The mock is being applied across the test suites. All implementations are now mocked. Also, mockRestore doesn't seem to work.
Additional information
No response
What version of Bun is running?
1.0.3+25e69c71e70ac8a0a88f9cf15b4057bd7b2a633a
What platform is your computer?
Linux 5.15.0-83-generic x86_64 x86_64
What steps can reproduce the bug?
MyModule.tsMyClassfrom the module with following structure:MyModule.test.tsOtherModule.test.tsmyMethod return valuetest starts failing like this:What is the expected behavior?
The mocks / spyOns should be contained within individual test suites.
What do you see instead?
The mock is being applied across the test suites. All implementations are now mocked. Also,
mockRestoredoesn't seem to work.Additional information
No response