[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix: allow hyphens in project config file name pattern (#9760)

Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>

authored by

Koutaro-Hanabusa
Hiroshi Ogawa
and committed by
GitHub
(Mar 5, 2026, 9:58 AM +0100) 33e96311 fc2cea2b

+37 -2
+7 -1
docs/guide/projects.md
··· 42 42 }) 43 43 ``` 44 44 45 - Vitest will treat every folder in `packages` as a separate project even if it doesn't have a config file inside. If the glob pattern matches a file, it will validate that the name starts with `vitest.config`/`vite.config` or matches `(vite|vitest).*.config.*` pattern to ensure it's a Vitest configuration file. For example, these config files are valid: 45 + Vitest will treat every folder in `packages` as a separate project even if it doesn't have a config file inside. If a project entry resolves to a file (either from a glob pattern or a direct file path), Vitest will validate that the name either: 46 + 47 + - starts with `vitest.config` or `vite.config` (for example, `vitest.config.unit.ts`) 48 + - or matches `vitest.<name>.config.*` / `vite.<name>.config.*`, where `<name>` can contain letters, numbers, `_`, and `-` 49 + 50 + For example, these config files are valid: 46 51 47 52 - `vitest.config.ts` 48 53 - `vite.config.js` 49 54 - `vitest.unit.config.ts` 55 + - `vitest.e2e-node.config.ts` 50 56 - `vite.e2e.config.js` 51 57 - `vitest.config.unit.js` 52 58 - `vite.config.e2e.js`
+28
test/cli/test/projects.test.ts
··· 181 181 expect(exitCode).toBe(0) 182 182 }) 183 183 184 + it('[glob] the name has "unit-test" (with hyphen) between "vitest" and "config" and works', async () => { 185 + const { exitCode } = await runInlineTests({ 186 + 'vitest.unit-test.config.js': {}, 187 + 'vitest.config.js': { 188 + test: { 189 + passWithNoTests: true, 190 + projects: ['./vitest.*.config.js'], 191 + }, 192 + }, 193 + }) 194 + 195 + expect(exitCode).toBe(0) 196 + }) 197 + 198 + it('[file] the name has "unit-test" (with hyphen) between "vitest" and "config" and works', async () => { 199 + const { exitCode } = await runInlineTests({ 200 + 'vitest.unit-test.config.js': {}, 201 + 'vitest.config.js': { 202 + test: { 203 + passWithNoTests: true, 204 + projects: ['./vitest.unit-test.config.js'], 205 + }, 206 + }, 207 + }) 208 + 209 + expect(exitCode).toBe(0) 210 + }) 211 + 184 212 it('[file] the name does not start with "vite"/"vitest" and throws an error', async () => { 185 213 const { stderr } = await runInlineTests({ 186 214 'unit.config.js': {},
+2 -1
packages/vitest/src/node/projects/resolveProjects.ts
··· 22 22 // vite.config.* 23 23 // vitest.unit.config.* 24 24 // vite.unit.config.* 25 - const CONFIG_REGEXP = /^vite(?:st)?(?:\.\w+)?\.config\./ 25 + // vitest.unit-test.config.* 26 + const CONFIG_REGEXP = /^vite(?:st)?(?:\.[\w-]+)?\.config\./ 26 27 27 28 export async function resolveProjects( 28 29 vitest: Vitest,