Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coverage command with Vitest won't return the coverage report. Why?

Any kind soul could help me to "How to use the command-line coverage in my Vitest and Typescript project"???? It simply won't return me the coverage report.

It only return me how many tests have passed and the ones that failed.

I've install the "@vitest/-coverage-v8" and the command i'm running in the terminal is "npx vitest run --coverage".

The funny thing is that appears in my terminal this: "Coverage enabled with v8". But it runs one time and then stop.

What i'm missing???

like image 285
Isa Moura Avatar asked Mar 18 '26 09:03

Isa Moura


2 Answers

First, make sure that @vitest/coverage-v8 is the same version as vitest. Then try setting tests.coverage.reportOnFailure to true if you're still not getting reports.

https://github.com/vitest-dev/vitest/issues/3259#issuecomment-1528875754 https://vitest.dev/config/#coverage-reportonfailure

like image 73
Jedai Saboteur Avatar answered Mar 20 '26 05:03

Jedai Saboteur


It will only show the report, when all of your tests are passed.

like image 40
Scrub Avatar answered Mar 20 '26 05:03

Scrub