Skip to content

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

Closed

Description

@EVWorth

Found while wiring the production guard (#588).

A test file in src/components/<area>/__tests__/ needs ../../../stores/x to reach src/stores/x. Nine mocks use ../../, which resolves to src/components/stores/x — a path that does not exist. Vitest does not error on an unresolvable vi.mock; it silently does nothing, so the suite runs against the real module and still passes.

Broken

  • src/components/backup/__tests__/RestoreDialog.test.tsx — ../../lib/sql-import, ../../lib/tauri-api, ../../stores/connectionStore (all three; the file mocks nothing it thinks it does)
  • src/components/connection/__tests__/ConnectionDialog.test.tsx — ../../lib/tauri-api, ../../stores/connectionStore
  • src/components/grid/__tests__/CellViewerModal.test.tsx — ../../stores/themeStore
  • src/components/layout/__tests__/MainPanel.test.tsx — ../../stores/editorStore, ../../stores/resultStore
  • src/components/favorites/__tests__/SaveFavoriteDialog.test.tsx — ../../stores/favoritesStore (already fixed in fix(favorites): refuse duplicate names, and stop a stray click renaming #583)

Why it matters

The assertions are not measuring what they name. SaveFavoriteDialog.test.tsx was the first one caught: twelve tests had been exercising the real favoritesStore, and a new test that should have been trivial failed in a way that made no sense until the real store’s generated id turned up in the output. The others are the same shape and none of them have been caught yet, because a suite running against real modules mostly still passes.

Expected

Every vi.mock path resolves. Fixing the paths will surface assertions that were only passing by accident; those are real findings, not collateral.

Proposed fix

Correct the paths, then add a check so it cannot recur — a script in scripts/ walking vi.mock("…relative…") specifiers and failing on any that resolves to no file, wired into CI beside check-documented-commands.sh. A lint rule would be neater if one exists for this.

Acceptance

No vi.mock specifier in src/** resolves to a non-existent path; CI fails if one is added.

Activity

  1. added
    severity/p1
    kind/test
    on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cross-cuttingkind/testseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions