Skip to content

Commit 64dc2f8

Browse files
committed
fix(test): pass --passWithNoTests to vitest
Scoped test runs (e.g. pre-commit --staged) that don't resolve to any test file should succeed rather than error with "No test files found".
1 parent 8eb516c commit 64dc2f8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

scripts/test.mts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,16 @@ async function runTests(
300300
const vitestCmd = WIN32 ? 'vitest.cmd' : 'vitest'
301301
const vitestPath = path.join(nodeModulesBinPath, vitestCmd)
302302

303-
const vitestArgs = ['--config', '.config/vitest.config.mts', 'run']
303+
// --passWithNoTests: a scoped run where the changed files don't resolve
304+
// to any test file should succeed rather than error with "No test files
305+
// found". Keeps pre-commit hooks passing when an edit touches only
306+
// non-testable code.
307+
const vitestArgs = [
308+
'--config',
309+
'.config/vitest.config.mts',
310+
'run',
311+
'--passWithNoTests',
312+
]
304313

305314
// Add coverage if requested
306315
if (coverage) {

0 commit comments

Comments
 (0)