Skip to content

Commit

Permalink
fix(coverage): exclude files and directories starting with dot by def…
Browse files Browse the repository at this point in the history
…ault (#4428)
  • Loading branch information
AriPerkkio authored Nov 4, 2023
1 parent a75228f commit b3327a6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ List of files included in coverage as glob patterns
[
'coverage/**',
'dist/**',
'**/[.]**',
'packages/*/test?(s)/**',
'**/*.d.ts',
'**/virtual:*',
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const benchmarkConfigDefaults: Required<Omit<BenchmarkUserOptions, 'outpu
const defaultCoverageExcludes = [
'coverage/**',
'dist/**',
'**/[.]**',
'packages/*/test?(s)/**',
'**/*.d.ts',
'**/virtual:*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ test('all includes untested files', () => {
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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file should be excluded from coverage report

export function uncoveredFile() {
return 0
}

0 comments on commit b3327a6

Please sign in to comment.