Test: fail the build when a test file is collected by no vitest project - #769
Open
AmaadMartin wants to merge 3 commits into
Open
Test: fail the build when a test file is collected by no vitest project#769AmaadMartin wants to merge 3 commits into
AmaadMartin wants to merge 3 commits into
Conversation
added 3 commits
August 7, 2026 05:00
tinyglobby is already installed and root-hoisted as a transitive dependency of vitest and vite. Declaring it lets a test import it without relying on a phantom hoisted package. No package is added to the tree.
Vitest skips a test file that matches no project include glob without any warning, so a contributor reads a green build as a passing test. This guard reads the include globs from vitest.config.ts, walks the working tree for test-looking filenames, and names every file that no project collects.
Vitest's default include is `**/*.{test,spec}.?(c|m)[jt]s?(x)`, so a
`foo.test.mts` a contributor adds outside every declared glob was still
silently uncollected and unguarded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Link to an existing issue (if applicable):
Or, if no issue exists, describe the change:
Problem: Vitest runs a test file only when some project's
includeglob matches it. A file that matches no glob is skipped in silence: no warning, no error, no "0 tests found". The contributor then reads a green build as a passing test.Solution: Add one repo-config test to the
integrationproject. It reads theincludeglobs out ofvitest.config.ts, walks the working tree for test-looking filenames, and fails with every path that no project collects. It reads the globs instead of hardcoding them, so a new project widens the guard on its own.Dependency: The guard imports
globSyncfromtinyglobby, the library Vitest and Vite themselves use to expandincludeglobs, so "is this file collected?" is the runner's answer rather than an approximation.tinyglobby@0.2.17is already installed and root-hoisted throughvitest@3.2.6andvite@7.3.5; this PR only declares it in the rootdevDependenciesso the import is not a phantom. The lockfile diff is one line and no package is added to the tree.Scope:
vitest.config.tsand thepackage.jsonscripts are unchanged.Collision check:
gh pr list --repo AmaadMartin/adk-js --state all --limit 400returns no PR that guards test-file collection. #343 and #418 add sibling guards in the same newtests/integration/repo_config/directory, but both check project-and-script wiring, under different filenames. This PR branches frommainand does not depend on either.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
npx vitest run --project integration tests/integration/repo_config/test_file_coverage_test.ts— 6 passed.Every test was proven able to fail. Each mutation was applied alone, then reverted:
ignore: IGNORED_DIRSexpected [ 'dist/built_test.ts', …(3) ] to deeply equal [ 'pkg/stray_test.ts', …(1) ].filter((file) => !collected.has(file))with.filter(() => true)includearrayexpected [Function] to throw error matching /project #0/ but it didn't!projectsguardTypeError: Cannot read properties of undefinedinstead of the named errorprojects.mapinstead ofprojects.flatMapThe extension list also has signal.
tests/scratch/probe_test.mtsandtests/scratch/probe.spec.ctsboth turn the guard red and are named in the diff.The whole repository is clean today, so the guard is green on
mainand only ever goes red on a regression.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
Step 2 fails and lists all four:
Toolchain, on the pushed commit:
npm run lintclean,npm run format:checkclean.npm run ts:checkreports 287 errors both with and without this branch, so the new file adds none; those errors are pre-existing onmain.CI is green on all three legs of the
run-testsmatrix. The guard passed onwindows-latesttoo, which is the leg that proves the path handling: both the collected set and the test-looking set come from the sameglobSynccall shape, so both are POSIX-separated paths relative to the repo root on every OS.Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.