diff --git a/docs/config/index.md b/docs/config/index.md index bba12aab15cf..33d656185c78 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -124,8 +124,8 @@ When using coverage, Vitest automatically adds test files `include` patterns to ### exclude - **Type:** `string[]` -- **Default:** `['**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*']` -- **CLI:** `vitest --exclude "**/excluded-file"` +- **Default:** `['**/node_modules/**', '**/.git/**']` +- **CLI:** `vitest --exclude "**/excluded-file" --exclude "*/other-files/*.js"` A list of glob patterns that should be excluded from your test files. diff --git a/docs/guide/improving-performance.md b/docs/guide/improving-performance.md index e9ed9a8bf81e..d34fc2889ac7 100644 --- a/docs/guide/improving-performance.md +++ b/docs/guide/improving-performance.md @@ -52,6 +52,10 @@ export default defineConfig({ ``` ::: +## Limiting directory search + +You can limit the working directory when Vitest searches for files using [`test.dir`](/config/#test-dir) option. This should make the search faster if you have unrelated folders and files in the root directory. + ## Pool By default Vitest runs tests in `pool: 'forks'`. While `'forks'` pool is better for compatibility issues ([hanging process](/guide/common-errors.html#failed-to-terminate-worker) and [segfaults](/guide/common-errors.html#segfaults-and-native-code-errors)), it may be slightly slower than `pool: 'threads'` in larger projects. diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index d5587c42fe97..d6580e7cc10c 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -12,10 +12,7 @@ export { defaultBrowserPort } from './constants' export const defaultInclude: string[] = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'] export const defaultExclude: string[] = [ '**/node_modules/**', - '**/dist/**', - '**/cypress/**', - '**/.{idea,git,cache,output,temp}/**', - '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*', + '**/.git/**', ] export const benchmarkConfigDefaults: Required< Omit diff --git a/packages/vitest/src/node/types/config.ts b/packages/vitest/src/node/types/config.ts index 53587926c2fb..30989b303a61 100644 --- a/packages/vitest/src/node/types/config.ts +++ b/packages/vitest/src/node/types/config.ts @@ -271,7 +271,7 @@ export interface InlineConfig { /** * Exclude globs for test files - * @default ['**\/node_modules/**', '**\/dist/**', '**\/cypress/**', '**\/.{idea,git,cache,output,temp}/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*'] + * @default ['**\/node_modules/**', '**\/.git/**'] */ exclude?: string[] diff --git a/test/cli/fixtures/dotted-files/.cache/projects/test/.cache/should-not-run.test.ts b/test/cli/fixtures/dotted-files/.cache/projects/test/.cache/should-not-run.test.ts deleted file mode 100644 index 00d2519d3d5d..000000000000 --- a/test/cli/fixtures/dotted-files/.cache/projects/test/.cache/should-not-run.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { expect, test } from 'vitest' - -test('should not run', () => { - expect(1).toBe(2) -})