diff --git a/docs/config/index.md b/docs/config/index.md index c5f888c90c6a..45fe17789f58 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -1102,7 +1102,7 @@ List of files included in coverage as glob patterns 'cypress/**', 'test?(s)/**', 'test?(-*).?(c|m)[jt]s?(x)', - '**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)', + '**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)', '**/__tests__/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*', '**/vitest.{workspace,projects}.[jt]s?(on)', diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index ae678886bf75..a07b50cd3d6f 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -23,7 +23,7 @@ const defaultCoverageExcludes = [ 'cypress/**', 'test?(s)/**', 'test?(-*).?(c|m)[jt]s?(x)', - '**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)', + '**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)', '**/__tests__/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*', '**/vitest.{workspace,projects}.[jt]s?(on)', diff --git a/packages/vitest/src/types/coverage.ts b/packages/vitest/src/types/coverage.ts index beddea8f79c8..1f84a86bb96e 100644 --- a/packages/vitest/src/types/coverage.ts +++ b/packages/vitest/src/types/coverage.ts @@ -121,7 +121,7 @@ export interface BaseCoverageOptions { /** * List of files excluded from coverage as glob patterns * - * @default ['coverage/**', 'dist/**', '**\/[.]**', 'packages/*\/test?(s)/**', '**\/*.d.ts', '**\/virtual:*', '**\/__x00__*', '**\/\x00*', 'cypress/**', 'test?(s)/**', 'test?(-*).?(c|m)[jt]s?(x)', '**\/*{.,-}{test,spec}.?(c|m)[jt]s?(x)', '**\/__tests__/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*', '**\/vitest.{workspace,projects}.[jt]s?(on)', '**\/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}'] + * @default ['coverage/**', 'dist/**', '**\/[.]**', 'packages/*\/test?(s)/**', '**\/*.d.ts', '**\/virtual:*', '**\/__x00__*', '**\/\x00*', 'cypress/**', 'test?(s)/**', 'test?(-*).?(c|m)[jt]s?(x)', '**\/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)', '**\/__tests__/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*', '**\/vitest.{workspace,projects}.[jt]s?(on)', '**\/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}'] */ exclude?: string[] diff --git a/test/coverage-test/src/should-be-excluded-from-report.test-d.ts b/test/coverage-test/src/should-be-excluded-from-report.test-d.ts new file mode 100644 index 000000000000..64bda3a2b8cb --- /dev/null +++ b/test/coverage-test/src/should-be-excluded-from-report.test-d.ts @@ -0,0 +1,5 @@ +// This file should be excluded from coverage report + +export function uncoveredFile() { + return 0 +}