Open bichikim opened 1 year ago
I have no idea about the mock module by using vite now. I will investigate how karma-typescript-mock and other libraries implement mock module.
By the way, currently, do you want global mocks or in-module mocks?
Vite
uses the es module, so we cannot directly modify the import results at runtime. That is, we cannot implement the mock module only at runtime like karma-typescript-mock.
But vitest
realizes module mocking in es module. Its principle is to use vite ssr to rewrite the import statement at compile time, and change its module loading method to runtime loading. But we can't use this function directly in the browser. So in order to implement this function, we need to implement the es module mock function ourselves. it will take some time
Therefore, in order to realize this function, we need to implement the es module mock function ourselves. This will take some time
I want the in-module mocks :) Thx your kind reply
I will research for the es module mock function you mentioned :)
Hi :)
Thank you for this awesome library.
Please tell me how to mock a module.
For example, karma-typescript-mock can mock a module.