diff --git a/docs/config/index.md b/docs/config/index.md index 6ee0d0dd3..42170d2c8 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -1066,6 +1066,7 @@ List of files included in coverage as glob patterns [ 'coverage/**', 'dist/**', + '**/[.]**', 'packages/*/test?(s)/**', '**/*.d.ts', '**/virtual:*', diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index 0d44c755e..4cfbfc802 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -13,6 +13,7 @@ export const benchmarkConfigDefaults: Required { const files = fs.readdirSync(coveragePath) expect(files).toContain('untested-file.ts.html') + + // Directories starting with dot should be excluded + expect(files).not.toContain('.should-be-excluded-from-coverage/excluded-from-coverage.ts.html') + expect(files).not.toContain('.should-be-excluded-from-coverage') + expect(files).not.toContain('excluded-from-coverage.ts.html') }) test('files should not contain query parameters', () => { diff --git a/test/coverage-test/src/.should-be-excluded-from-coverage/excluded-from-coverage.ts b/test/coverage-test/src/.should-be-excluded-from-coverage/excluded-from-coverage.ts new file mode 100644 index 000000000..64bda3a2b --- /dev/null +++ b/test/coverage-test/src/.should-be-excluded-from-coverage/excluded-from-coverage.ts @@ -0,0 +1,5 @@ +// This file should be excluded from coverage report + +export function uncoveredFile() { + return 0 +}