Skip to content

fix(test): pass --passWithNoTests to vitest#598

Open
John-David Dalton (jdalton) wants to merge 1 commit intomainfrom
fix/test-passwithNoTests
Open

fix(test): pass --passWithNoTests to vitest#598
John-David Dalton (jdalton) wants to merge 1 commit intomainfrom
fix/test-passwithNoTests

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

Summary

  • When a scoped test run (pre-commit hook with --staged, or any partial scope) only touches files that don't map to any test file, vitest exits with code 1 and "No test files found".
  • That's a false failure — a scope that happens to produce zero matches should succeed, not block a commit.
  • Add --passWithNoTests to the vitest args so the exit code reflects actual test outcomes.

Test plan

  • pnpm test on a change that only touches non-test files (e.g. a README edit) no longer errors
  • pnpm test that does touch tests still runs and fails/passes correctly
  • Pre-commit hook passes on commits that don't affect tests

When a scoped test run (e.g. pre-commit hook with --staged) only touches
files that don't map to any test, vitest exits 1 with "No test files
found". That's a false positive — a scope producing zero matches should
succeed, not fail the commit.

Add --passWithNoTests so the exit code reflects test outcomes, not
whether the pattern happened to match a file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant