You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The config states that I am interested in asserting the test coverage for my tests and have them fail if they don't meet the treshold (which are in this example 100%).
Due to the recent issues with creating test coverage reports, e.g. in #3125, we found out that our tests were not validated against our given treshold causing pull requests that decreased the overall coverage in our test suite to just pass. After we fixed the issue by updating the dependencies of vitest and @vitest/c8-coverage, coverage reports were created again but we got surprised by the failing treshold validation.
I think it is a bug if Vitest should ignores the treshold validation due to missing coverage reports. If test coverage validation is enabled by providing a statements, branches, functions or lines property, Vitest should ensure that the validation happens and fails if for some reasons it can't find any coverage data.
In [email protected] the #3040 introduced an API mismatch bug where vitest was unable to load @vitest/coverage-c8 package if version of @vitest/coverage-c8 was not 0.29.8 as well. In 0.30.0 this is fixed. Your reproduction case is running into this old (already fixed) bug. It's using [email protected] and @vitest/[email protected].
As the whole coverage provider package fails to load we cannot do anything coverage related - checking thresholds here would require duplicating the logic from coverage package to vitest core package. But I think we can improve the situation by failing whole process if there is coverage.enabled: true and the coverageModule below is falsy. So instead of silently failing to load the coverage package (and disabling coverage) due to possible API mismatch bugs, we'll fail the whole process.
Describe the bug
Given I have a
vitest.conf.js
defined as following:The config states that I am interested in asserting the test coverage for my tests and have them fail if they don't meet the treshold (which are in this example 100%).
Due to the recent issues with creating test coverage reports, e.g. in #3125, we found out that our tests were not validated against our given treshold causing pull requests that decreased the overall coverage in our test suite to just pass. After we fixed the issue by updating the dependencies of
vitest
and@vitest/c8-coverage
, coverage reports were created again but we got surprised by the failing treshold validation.I think it is a bug if Vitest should ignores the treshold validation due to missing coverage reports. If test coverage validation is enabled by providing a
statements
,branches
,functions
orlines
property, Vitest should ensure that the validation happens and fails if for some reasons it can't find any coverage data.Reproduction
Open with VS Code:
or manually check out: https://github.com/christian-bromann/vitest-coverage-bug
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: