You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using vi.mock('./SomeClass.ts'); to mock a module that is a class exported as default export class SomeClass {...}, it will have all of its instances to share the same 'mock' attribute in the methods.
And if your code create multiple instances of that SomeClass, it is not possible to check if a method was called from one or the other instance as both will share the mock attribute.
This works fine in Jest, both checks above will be false.
Describe the bug
When using
vi.mock('./SomeClass.ts');
to mock a module that is a class exported asdefault export class SomeClass {...}
, it will have all of its instances to share the same 'mock' attribute in the methods.And if your code create multiple instances of that
SomeClass
, it is not possible to check if a method was called from one or the other instance as both will share themock
attribute.This works fine in Jest, both checks above will be false.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-i4zx4z?file=test%2Fbasic.test.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: