Why does code coverage in a monorepo require a root vitest.config.ts? #454
-
Hey all, I'm setting up code coverage in a monorepo. Previously I had...
However I found that with this setup, no code coverage was being output. When I added the following extra
It's not clear to me why this is needed - why doesn't the extension pick up the coverage config from the individual packages? Have I missed something? It's also not clear to me whether I should be configuring coverage in this root file or in the individual workspace config files. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Even with Vitest CLI, you will not get the coverage if you run it from the root. Of course, if you run tests from the project directory, Vitest will pick up its config and won't use workspaces at all - then it will print the coverage, but it will be scoped only to the project itself. This limitation exists because coverage is reported for every workspace project - you can't reconfigure it midthrough. That's the whole point of the workspace. |
Beta Was this translation helpful? Give feedback.
coverage
field never worked with workspace project's configs:Even with Vitest CLI, you will not get the coverage if you run it from the root. Of course, if you run tests from the project directory, Vitest will pick up its config and won't use workspaces at all - then it will print the coverage, but it will be scoped only to the project itself.
This limitation exists because coverage is reported for every workspace project - you can't reconfigure it midthrough. That's the whole point of the workspace.