Skip to content

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

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

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

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

@jdalton John-David Dalton (jdalton) commented Apr 18, 2026

Summary

  • When a scoped test run (pre-commit hook with `--staged`, or an edit that doesn't touch testable code) produces glob/arg patterns that match no test files, `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 in `packages/cli/scripts/test-wrapper.mts` so the exit code reflects actual test outcomes.

Context

This is part of a cross-repo consistency pass — the same fix has been applied to socket-btm, socket-lib, socket-registry, socket-sdxgen, socket-packageurl-js, socket-tui, and socket-repo-template. socket-sdk-js has its own PR: SocketDev/socket-sdk-js#598

Test plan

  • Run `pnpm test` on a change that only touches non-test files (e.g. a README edit) — should no longer error
  • Run `pnpm test` that does touch tests — should still run and fail/pass correctly
  • Pre-commit hook passes on commits that don't affect tests

Note

Low Risk
Low risk: only changes the Vitest invocation flag so scoped runs with zero matched tests exit successfully; no production code paths are affected.

Overview
Updates the CLI test-wrapper.mts to always run Vitest with --passWithNoTests, so scoped/globbed test runs that match no files no longer fail with a non-zero exit code.

Adds a short inline comment explaining the pre-commit/scoped-run motivation.

Reviewed by Cursor Bugbot for commit 5748ddf. Configure here.

When a scoped test run (e.g. pre-commit hook with --staged, or an edit
that doesn't touch testable code) produces glob/arg patterns that match
no test files, vitest exits 1 with "No test files found". That's a false
positive — a scope producing zero matches should succeed, not block a
commit.

Add --passWithNoTests so the exit code reflects test outcomes, not
whether the patterns happened to match files.
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