Test file names
The presets pick test files by folder and by name. The globs live in
buddyConfigDefaults.
Folders
Section titled “Folders”Tests live under src, source, code, or tests, at the root of the Vitest project. Coverage counts source files
under src, source, or code only.
A test file is <name>.<id>.<ext> or <name>.<id>.<platform>.<ext>. <id> is one of spec, test, unit,
accept, integrate, system, perf, stress, or study. Load tests use <name>.load.<ext> instead.
| Kind | Example | Glob key | Run by |
|---|---|---|---|
| general | a.spec.ts, a.unit.mjs |
testGeneral |
either preset, with includeGeneralTests: true |
| Node.js | a.spec.node.ts |
testNode |
nodeTestPreset() |
| browser | a.spec.browser.ts, a.spec.tsx |
testBrowser |
browserTestPreset(), or nodeTestPreset() with environment: 'jsdom' or 'happy-dom' |
| load | a.load.ts |
testLoad |
either preset, with includeLoadTests: true |
Rules the globs encode:
- A general test uses a
js,cjs,mjs,ts,cts, ormtsextension. A.jsxor.tsxtest is a browser test. - The platform segment starts with
nodeorbrowser, soa.spec.node.tsanda.spec.browser.tsboth match. - A Node.js test cannot use
.jsxor.tsx. A browser test with abrowsersegment can use any of the extensions. - Load tests use
js,cjs,mjs,ts,cts, ormts.
Exact globs
Section titled “Exact globs”// include.testGeneral'{src,source,code,tests}/**/*.{spec,test,unit,accept,integrate,system,perf,stress,study}.{js,cjs,mjs,ts,cts,mts}'
// include.testNode'{src,source,code,tests}/**/*.{spec,test,unit,accept,integrate,system,perf,stress,study}.node*.{js,cjs,mjs,ts,cts,mts}'
// include.testBrowser'{src,source,code,tests}/**/*.{spec,test,unit,accept,integrate,system,perf,stress,study}.{jsx,tsx}''{src,source,code,tests}/**/*.{spec,test,unit,accept,integrate,system,perf,stress,study}.browser*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}'
// include.testLoad'{src,source,code,tests}/**/*.load.{js,cjs,mjs,ts,cts,mts}'Coverage
Section titled “Coverage”Both presets set test.coverage:
// include.source → coverage.include'{src,source,code}/**/*.{js,mjs,cjs,ts,jsx,tsx,cts,mts}'
// exclude.test → coverage.exclude'**/*.{spec,test,unit,accept,integrate,system,perf,stress,study,load}.{js,jsx,cjs,mjs,ts,tsx,cts,mts}''**/*.{spec,test,unit,accept,integrate,system,perf,stress,study,load}.*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}''**/*.stories.{js,mjs,jsx,tsx}'Coverage excludes test files, load files, and Storybook stories (.js, .mjs, .jsx, .tsx only).