How to get code coverage for scripts called as worker process/thread? #3851
-
|
I have run vitest on functions that call worker process (or worker thread) internally as shown below, but I can't seem to get code coverage for the worker script. Is there any way (or options) to get coverage of scripts called by
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
I found a similar issue registered in Jest, but it seems that it has not been resolved yet. Is this possible in Vitest unlike Jest? Or is there any plan to support it in the future? |
Beta Was this translation helpful? Give feedback.
-
|
Vitest can collect coverage of files that are loaded through Vite. Files that are run using Even if Vitest used tools like There's some related discussion here: #2911. |
Beta Was this translation helpful? Give feedback.
Vitest can collect coverage of files that are loaded through Vite. Files that are run using
node:worker_threads,node:child_processorrequire()are not intercepted by Vite. This also means that Vitest mocks or other similar features are not available inside such files.Even if Vitest used tools like
spawn-wrapto overwritenode:child_processAPIs just for code instrumentation, we would still need to figure out where to get source maps as Vite would not have those now. I'm not saying it's impossible, but I think it would require quite complex setup.There's some related discussion here: #2911.