Open kwojcik opened 2 weeks ago
Found the workaround, you need to include coverageConfigDefaults.exclude
. I was previously including configDefaults.exclude
.
exclude: ['stuff/*', ...coverageConfigDefaults.exclude],
It is expected that coverage picks up a test file if you override exclude
because test files are not forcefully excluded anymore: https://github.com/vitest-dev/vitest/pull/5997 (they excluded only if exclude
is not overridden)
It is unexpected that it throws an error in vi.hoisted
though.
@sheremet-va How about excluding .vue files imported in .js test files from coverage report? how can we do that? Please check this for details: https://github.com/vitest-dev/vitest/issues/6058#issuecomment-2215071109
It's expected that this file is instrumented when you disable all coverage.excludes
and use the default coverage.includes: ['**']
.
The reason why this errors comes up is that vitest:mocks
plugin has bug:
// input
import { vi } from "vitest";
const mocks = (cov_29w8m57srg().s[0]++, vi.hoisted(() => {
cov_29w8m57srg().f[0]++;
cov_29w8m57srg().s[1]++;
return {};
}));
// output
const mocks = (cov_29w8m57srg().s[0]++, );
Describe the bug
If you use istanbul coverage (required for browser mode), override the coverage
excludes
, and usevi.hoisted
, then your test runs fail with cryptic syntax errors.This worked on
v2.0.0-beta.12
and is broken onv2.0.1
.Reproduction
https://github.com/kwojcik/vitestsourcemapbug/tree/hoistedBug
System Info
Used Package Manager
npm
Validations