diff --git a/docs/config/index.md b/docs/config/index.md index 37ba61e626e6..c145f9c29552 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -81,7 +81,7 @@ All configuration options that are not supported inside a [workspace](/guide/wor ### include - **Type:** `string[]` -- **Default:** `['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']` +- **Default:** `['**/__tests__/**/*.?(c|m)[jt]s?(x)', '**/?(*.){test,spec}.?(c|m)[jt]s?(x)']` Files to include in the test run, using glob pattern. @@ -206,7 +206,7 @@ Options used when running `vitest bench`. #### benchmark.include - **Type:** `string[]` -- **Default:** `['**/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']` +- **Default:** `['**/*.{bench,benchmark}.?(c|m)[jt]s?(x)']` Include globs for benchmark test files @@ -698,16 +698,15 @@ List of files included in coverage as glob patterns [ 'coverage/**', 'dist/**', - 'packages/*/test{,s}/**', + '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}', + '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.*', - '**/.{eslint,mocha,prettier}rc.{js,cjs,yml}', + '**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}', ] ``` - **Available for providers:** `'c8' | 'istanbul'` @@ -1328,7 +1327,7 @@ You can also pass down a path to custom binary or command name that produces the #### typecheck.include - **Type**: `string[]` -- **Default**: `['**/*.{test,spec}-d.{ts,js}']` +- **Default**: `['**/?(*.){test,spec}-d.?(c|m)[jt]s?(x)']` Glob pattern for files that should be treated as test files diff --git a/package.json b/package.json index 1c7c54fa6342..29370629d3c4 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "pre-commit": "npx lint-staged" }, "lint-staged": { - "*.{js,ts,tsx,vue,md}": [ + "*.{[jt]s?(x),vue,md}": [ "eslint --cache --fix" ] } diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index f06e14bf4c65..e7f5e8242873 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -1,10 +1,10 @@ import type { BenchmarkUserOptions, ResolvedCoverageOptions, UserConfig } from './types' import { isCI } from './utils/env' -export const defaultInclude = ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'] +export const defaultInclude = ['**/__tests__/**/*.?(c|m)[jt]s?(x)', '**/?(*.){test,spec}.?(c|m)[jt]s?(x)'] export const defaultExclude = ['**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*'] export const benchmarkConfigDefaults: Required> = { - include: ['**/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + include: ['**/*.{bench,benchmark}.?(c|m)[jt]s?(x)'], exclude: defaultExclude, includeSource: [], reporters: ['default'], @@ -13,16 +13,15 @@ export const benchmarkConfigDefaults: Required