Skip to content

fix(test): close the Node-version guard's remaining coverage gap#7629

Merged
JSONbored merged 1 commit into
mainfrom
claude/vitest-global-setup-node-version
Jul 21, 2026
Merged

fix(test): close the Node-version guard's remaining coverage gap#7629
JSONbored merged 1 commit into
mainfrom
claude/vitest-global-setup-node-version

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Closes #7627

Summary

  • pretest* hooks (fix(test): enforce the Node version pin on every test run, not just install #7619) only cover 5 npm script names and can never cover a direct npx vitest run <file> call, which the contributing docs explicitly recommend for fast iteration. Adds a vitest
    globalSetup wired into all 6 vitest configs in the repo, closing the gap completely regardless of
    invocation path -- current or future script name, or a direct npx vitest call.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • 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 instead of new tests: a direct
    npx vitest run <file> on Node 26 now fails immediately via globalSetup with a clear message, checked
    both at the repo root and inside apps/loopover-ui (the workspace where the underlying Node-26 bug
    actually lived).

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

Not applicable — no visible UI/frontend change (test infrastructure only).

Notes

#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 found this misses 8 of 12 vitest-invoking script
names (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 reference.md and SKILL.md both explicitly
recommend for fast iteration -- since that command doesn't go through
any npm script at all.

Add test/helpers/vitest-global-setup-node-version.ts, wired as
`globalSetup` in every vitest.config.ts in the repo (root, workers,
and every workspace with its own config). globalSetup runs once
before any test file regardless of invocation path, closing the gap
completely instead of requiring anyone to remember a matching
pretest* entry for every current and future script name.

Verified directly on Node 26: a direct `npx vitest run <file>` now
fails immediately via globalSetup, both at the root and inside
apps/loopover-ui -- no confusing downstream test failures, one clear
message. The existing pretest* hooks stay as a genuinely-faster fail
for the 5 high-traffic commands (they run before npm even spawns
vitest); check-node-version.mjs's header comment now describes
globalSetup as the real guarantee and the hooks as a nicety on top.

Closes #7627
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 9b46d3e Commit Preview URL

Branch Preview URL
Jul 21 2026, 05:06 AM

@JSONbored JSONbored self-assigned this Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@JSONbored
JSONbored merged commit 9f356fe into main Jul 21, 2026
18 checks passed
@JSONbored
JSONbored deleted the claude/vitest-global-setup-node-version branch July 21, 2026 05:12
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant