Repository navigation
test: make nine vi.mock paths resolve, and stop it recurring - #596
Merged
Merged
Conversation
A test file in src/components/<area>/__tests__/ needs ../../../stores/x to reach src/stores/x. Nine mocks used ../../, which lands in src/components/stores/x — nowhere. Vitest does not error on an unresolvable vi.mock path; it silently does nothing, so the suite runs against the real module and passes anyway (#594). RestoreDialog.test.tsx mocked nothing it thought it did: all three of its mocks were wrong. ConnectionDialog had two, MainPanel two, CellViewerModal one, SaveFavoriteDialog one. Nothing was going to find these. The first was caught by accident while adding a favorites test that should have been trivial and failed in a way that made no sense until the real store's generated id turned up in the output — a suite running against real modules mostly still passes, which is exactly what makes the failure mode quiet. All 107 tests in the four affected files still pass with the mocks now live, so nothing here was passing by accident. That is worth stating rather than assuming: it was the plausible outcome either way. scripts/check-test-mocks.sh walks every relative vi.mock specifier and fails on any that resolves to no file. Verified it catches a reintroduced break before trusting the pass. CI runs it when frontend or scripts change. The find needs -type f: __screenshots__ directories are named after the test file that produced them, so a bare -name hands grep a directory. Closes #594 Co-Authored-By: Claude Opus 5 <[email protected]>
EVWorth
force-pushed
the
fix/broken-vi-mock-paths
branch
from
September 9, 2026 23:56
a2eda8b to
3178b08
Compare
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.
Closes #594. Found while wiring #588.
A test file in
src/components/<area>/__tests__/needs../../../stores/xto reachsrc/stores/x. Nine mocks used../../, which lands insrc/components/stores/x— nowhere. Vitest does not error on an unresolvablevi.mockpath. It silently does nothing, so the suite runs against the real module and passes anyway.RestoreDialog.test.tsxConnectionDialog.test.tsxMainPanel.test.tsxCellViewerModal.test.tsxSaveFavoriteDialog.test.tsxNothing was going to find these. The first was caught by accident: a favorites test that should have been trivial failed in a way that made no sense until the real store's generated id appeared in the output.
All 107 tests in the affected files still pass with the mocks live
Worth stating plainly rather than assuming — it was the plausible outcome either way, and it means nothing here was passing by accident.
The guard
scripts/check-test-mocks.shwalks every relativevi.mockspecifier and fails on any that resolves to no file. Verified it catches a reintroduced break (exit 1, names the file and specifier) before trusting the pass. CI runs it whensrc/**orscripts/**change.One wrinkle worth the comment it got:
findneeds-type f, because__screenshots__directories are named after the test file that produced them and a bare-namehands grep a directory.