Skip to content

fix(test): Node-version guard misses 8 of 12 vitest scripts and all direct npx vitest calls #7627

Description

@JSONbored

Context

#7619 wired scripts/check-node-version.mjs as a pretest* hook on 5 npm script names (test,
test:ci, test:coverage, test:workers, ui:test). A repo-wide audit after it shipped found this
misses 8 of the 12 vitest-invoking script names in root package.json (test:unit, test:integration,
test:upstream-contract, test:engine-parity, test:live-gate-parity, test:driver-parity,
test:changed, test:watch) -- npm's pre<name> hook only fires for the exact script name it's wired
to. Worse: this class of mechanism can never cover a direct npx vitest run test/unit/<file>.test.ts
invocation, which .claude/skills/contributing-to-loopover/reference.md and SKILL.md both explicitly
recommend for fast iteration while writing tests -- that command doesn't go through any npm script at
all, so no number of pretest* entries closes the gap.

Requirements

  • Add a vitest globalSetup (test/helpers/vitest-global-setup-node-version.ts, reusing
    checkNodeVersion from scripts/check-node-version.mjs) that runs once before any test file,
    regardless of invocation path.
  • Wire it into every vitest.config.ts in the repo: root, vitest.workers.config.ts, and every
    workspace with its own config (apps/loopover-ui, apps/loopover-miner-ui,
    packages/loopover-ui-kit, apps/loopover-miner-extension).
  • Keep the existing pretest* hooks as a genuinely-faster fail for the 5 high-traffic commands (they run
    before npm even spawns vitest); update check-node-version.mjs's own header comment so it accurately
    describes globalSetup as the real guarantee and the hooks as a nicety on top, not a substitute.

Deliverables

  • test/helpers/vitest-global-setup-node-version.ts added.
  • globalSetup wired into all 6 vitest configs.
  • Verified directly (not just asserted): a direct npx vitest run <file> on Node 26 now fails
    immediately via globalSetup, both at the root and inside apps/loopover-ui.
  • npm run test:ci green on Node 22.
  • .claude/skills/contributing-to-loopover/reference.md documents the globalSetup mechanism.

Test Coverage Requirements

The new helper and every touched vitest config live outside Codecov's src/**-only include glob, so
this owes no patch-coverage number. Verified via direct reproduction on Node 26 instead (see Deliverables).

Expected Outcome

Every vitest invocation path -- any current or future npm script name, and any direct npx vitest call
-- fails immediately and clearly on the wrong Node version, with no gap requiring anyone to remember to
wire a new pretest* entry.

Links & Resources

Metadata

Metadata

Assignees

Labels

gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions