-
I realised (eventually) that vi.mock silently omits mocking modules which are loaded using
Is there a standard answer for mocking CommonJS style imports that is compatible with vitest? I'm assuming that blending Everything else about my test suite (in a commonJS repository) is working well with no transpilation or build step - I am seamlessly using Typescript to author tests against functions defined using commonjs formalisms. However, the one occasion where I need to mock a required module is turning out to be very costly. To fulfil the requirements of What options do I have for mocking a module loaded with |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 13 replies
-
Vitest doesn't intercept |
Beta Was this translation helpful? Give feedback.
-
Adopting |
Beta Was this translation helpful? Give feedback.
-
Can somebody post some code snipped with a working mock-require implementation? That would be very helpful 👍 |
Beta Was this translation helpful? Give feedback.
Adopting
mock-require
in the test suite was an effective workaround.