Skip to content

test: make nine vi.mock paths resolve, and stop it recurring - #596

Merged
EVWorth merged 1 commit into
mainfrom
fix/broken-vi-mock-paths
Sep 10, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/broken-vi-mock-paths

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Closes #594. Found while wiring #588.

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.

File Broken mocks
RestoreDialog.test.tsx 3 — every mock in the file
ConnectionDialog.test.tsx 2
MainPanel.test.tsx 2
CellViewerModal.test.tsx 1
SaveFavoriteDialog.test.tsx 1 (also fixed in #583; identical change, merges clean)

Nothing 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.sh walks every relative vi.mock specifier 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 when src/** or scripts/** change.

One wrinkle worth the comment it got: find needs -type f, because __screenshots__ directories are named after the test file that produced them and a bare -name hands grep a directory.

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
EVWorth force-pushed the fix/broken-vi-mock-paths branch from a2eda8b to 3178b08 Compare September 9, 2026 23:56
@EVWorth
EVWorth merged commit 8229321 into main Sep 10, 2026
12 checks passed
@EVWorth
EVWorth deleted the fix/broken-vi-mock-paths branch September 10, 2026 00:01
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.

[P1/test] Nine vi.mock paths resolve to nothing; those suites test the real modules

1 participant