From 576d791310cd95af9c7a638d568957d63cd49a5d Mon Sep 17 00:00:00 2001 From: Abdellah Alaoui Solaimani Date: Thu, 27 Oct 2022 09:56:25 +0300 Subject: [PATCH] fix: improve config's default exclude (#2188) * ignore configuration files by default * add config exclude to the docs * Update packages/vitest/src/defaults.ts Co-authored-by: Vladimir * add config to default coverage excludes * add coverage exclude to docs * exclude other config files and update docs Co-authored-by: Vladimir Co-authored-by: Vladimir --- docs/config/index.md | 4 ++-- packages/vitest/src/defaults.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index 64bcd6069b36..c28425929c18 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -81,7 +81,7 @@ Files to include in the test run, using glob pattern. ### exclude - **Type:** `string[]` -- **Default:** `['**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**']` +- **Default:** `['**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*']` Files to exclude from the test run, using glob pattern. @@ -536,7 +536,7 @@ List of files included in coverage as glob patterns ##### exclude - **Type:** `string[]` -- **Default:** `[]` +- **Default:** `['coverage/**', 'dist/**', 'packages/*/test{,s}/**', '**/*.d.ts', 'cypress/**', 'test{,s}/**', 'test{,-*}.{js,cjs,mjs,ts,tsx,jsx}', '**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}', '**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}', '**/__tests__/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}', '**/.{eslint,mocha,prettier}rc.{js,cjs,yml}']` List of files excluded from coverage as glob patterns. diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index 881bc0c3aee5..597ade0dc909 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -1,8 +1,7 @@ import type { BenchmarkUserOptions, ResolvedCoverageOptions, UserConfig } from './types' export const defaultInclude = ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'] -export const defaultExclude = ['**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**'] - +export const defaultExclude = ['**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*'] export const benchmarkConfigDefaults: Required> = { include: ['**/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], exclude: defaultExclude, @@ -21,7 +20,7 @@ const defaultCoverageExcludes = [ '**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}', '**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}', '**/__tests__/**', - '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}', + '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*', '**/.{eslint,mocha,prettier}rc.{js,cjs,yml}', ]