Skip to content

Node test files run with node --test in repos that use vitest (#4586) - #4626

Merged
capy-ai[bot] merged 4 commits into
mainfrom
fix/pregate-node-test-files-run-with-node
Nov 21, 2026
Merged

capy-ai[bot] merged 4 commits into
mainfrom
fix/pregate-node-test-files-run-with-node

Conversation

@garrytan

@garrytan garrytan commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Test files that use Node's built-in test runner (node:test) now run with node --test in repos whose package.json declares vitest or jest, so /ship's pre-merge test check stops failing on them.
Before, a root .js, .mjs or .cjs file that loads node:test was handed to vitest, which found no tests and failed every PR that touched one. Reported by @eoin-obrien in #4586.
Nothing to do.

What changed

A node:test file in a vitest repo now gets node --test instead of vitest

A node:test file in a vitest repo now gets node --test instead of vitest.

In a pnpm monorepo whose root package.json declares vitest, /ship stopped at its finish step on every PR that touched a root node:test script test: the check ran that file under vitest, vitest found no suite, and the run failed. The runner detection now looks at the file itself. A .js, .mjs or .cjs test that loads node:test at the start of a line (an import, a bare import or a require) runs as its own node --test group from the repo root, while vitest and jest files keep their runner. A file that also loads vitest or @jest/globals stays with that runner, and import text inside comments, strings or template literals doesn't count. Bun repos are unchanged because bun test runs node:test files itself, and a runner declared in .gstack/pregate.json still takes every file.

One existing assertion changed on purpose. The "negative controls … keep today's plan" test pinned the fixture file test/util.test.js, which requires node:test, to vitest in a root-vitest repo. That expectation was the #4586 bug itself, so it now expects vitest for the vitest file and node --test for the node:test file.

No outside code was carried over. The issue's fixture was rebuilt from scratch in the new test.

Why

/ship should only fail for a real test failure. A repo mixing vitest with Node's own test runner is common in pnpm monorepos, and today every PR in such a repo that touches one of those files stops at the finish step for a reason that has nothing to do with the change.

Blast radius

Only runner detection for JS test files changes: detectRunner and planRuns in lib/pregate/checks/lanes.ts (read at lines 53-66 and 233-300). Repos that declare a runner, bun repos, and files that don't load node:test get the same plan as before; the existing bun-repo and declared-runner tests pin that, and the 93 focused tests in the selection, Dart and Rust suites pass.

Pre-Landing Review

Two full review passes, one fix round, and one granted follow-up check. The first pass found that a .js file importing both vitest and node:test went to node --test; that was fixed. A second-model review then found the fix misread import text inside template literals; that was fixed under one granted follow-up check, which came back clean. Remaining items are below the blocking floor and listed under Review notes.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL sf-89c56ae1f58f security finding, details recorded privately
  • INFORMATIONAL lib/pregate/checks/lanes.ts:205 A jest-globals or mocha file that imports node:test helpers is still routed to node --test; pre-existing before the fix.
  • INFORMATIONAL lib/pregate/checks/lanes.ts:203 Dynamic import('vitest') is not seen by the exclusion; rare and fails loudly.
  • INFORMATIONAL lib/pregate/checks/lanes.ts:203 The template-literal strip does not handle nested templates: a node:test file whose template holds a nested template with line-start vitest import text still goes to vitest.
Exploratory QA

Five probes against a scratch repo (root package.json declaring vitest), run through the real planRuns: a node:test .mjs file gets node --test and a .ts vitest file keeps vitest; node --test then runs that file and passes (1 test); a .js file importing both vitest and node:test went to node --test before the first fix and stays on vitest after it; a node:test file holding generated vitest text in a template literal gets node --test at the first commit and after the second fix, and went to vitest only at the head between them. No probe was blocked or skipped.

Eval Results

No prompt-related files changed, so evals were skipped.

TODOS

No TODO items completed in this PR.

Documentation

Status: updated. One factual edit, no blockers.

Scope: committed diff bd77c8c..9ae8c3a on fix/pregate-node-test-files-run-with-node (lib/pregate/checks/lanes.ts, test/pregate-selection.test.ts, changelog.d/fix-pregate-node-test-files-run-with-node.md); no staged, unstaged or untracked changes.

Documentation health:

  • docs/pregate.md: Updated. The runner row now says .js/.mjs/.cjs tests that load node:test (and not vitest or @jest/globals) run through node --test from the repo root even in vitest or jest repos, while bun repos keep bun test.
  • changelog.d/fix-pregate-node-test-files-run-with-node.md: Current.

Coverage debt: the new node:test runner detection is covered by reference docs only (the docs/pregate.md runner row); there is no how-to, which is fine for internal detection behavior. No diagram drift.

Tests
  • bun test test/pregate-selection.test.ts test/pregate-dart.test.ts test/pregate-rust.test.ts: 93 pass, 0 fail at the final tree.
  • Failing first: the new template-literal assertion fails with the lanes.ts change removed (0 pass, 1 fail) and passes with it.
  • test/pregate-environment.test.ts was left out of the local run: its "a guard whose binary is missing" case times out at 5 s on the 4-core build machine, on main bd77c8c too (2 of 2 runs). CI runs the full suite.
Agent notes

Agent notes

Refs #4586
Refs p1/specialist-batched#1
Refs p2/outside-voice#1

REVIEW_LOOP: passes=2 blocking_found=1 deferred=0 noted=4 fixed=2 scope=frozen ledgers_read=4 fix_checks=1 dispatches=6
Gate edits: none detected (2 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Second-model review: openai/gpt-6.1-sol, completed (one blocker, fixed under grant a-297338dfb7a8)
Scoped read of the post-review docs edit (docs/pregate.md): clean

Approved: yes (record r-e9e663370312). The full approval record stays private.
Plan: exempt: bug fix with a failing-first test (R4, R65)
Plan check: exempt bug fix

🤖 Generated with Claude Code

Open in Capy

{
  "schema_version": 1,
  "pr": 4626,
  "head": "f922f6e620712722d1f1fa943571e9a259f38e6d",
  "version": "1.102.1.0",
  "base": "main",
  "gate": {
    "pregate": {
      "pass": 93,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 44929655809,
      "attempt": 1,
      "tree": "9943075346347537ecfb47ba326bb5b9569a4c40"
    }
  ],
  "calls": 35,
  "session_kind": "unattended",
  "run": "/home/user/.capy/work/ship-4586/run1",
  "head_tree": "9943075346347537ecfb47ba326bb5b9569a4c40",
  "product_patch_id": "914de54b6567b5d61c8e87e9ac84becd702fc25d",
  "gstack_version": "1.102.1.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 16,
    "rules": "85b3923b1a978e41",
    "base": "bd77c8ccaa373e3a072ef3d9f4839edae16b46f0",
    "registry": "bd77c8ccaa373e3a072ef3d9f4839edae16b46f0",
    "gate_scan": {
      "tagged": 0,
      "head": "f922f6e620712722d1f1fa943571e9a259f38e6d"
    },
    "reasons": [
      "gate-class",
      "runtime=16"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @994307534634 (8 checks, current for f922f6e62071)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44929655809/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44929201483/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=994307534634 tests=38686 skipped=67 runs=44929655809/1 profiles=ci-reuse/free-tests heads=f922f6e62071 verified=2026-11-21T17:28:04.944Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      4586
    ],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/ and README.md (docs/pregate.md runner row updated)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 4,
    "fixed": 2,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 2,
    "ledgers_read": 4,
    "dispatches": {
      "specialist": 6
    }
  },
  "gate_dispositions": []
}

garrytan and others added 4 commits November 21, 2026 16:15
The pre-merge test check handed root .js/.mjs/.cjs files that load node:test to the repo vitest, which finds no suite in them and fails, so /ship stopped at finish. detectRunner now gives files that all load node:test node --test ahead of vitest and jest (bun still runs them), and planRuns splits them out of the root group. Reported by @eoin-obrien in #4586.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A JS test that loads vitest or @jest/globals beside node:test stays with that runner.

Review-Finding: p1/specialist-batched#1 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Import text inside a template literal no longer decides which runner a JS test gets.

Review-Finding: p2/outside-voice#1 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot merged commit f71e785 into main Nov 21, 2026
76 checks passed
@garrytan garrytan mentioned this pull request Nov 21, 2026
capy-ai Bot added a commit that referenced this pull request Nov 21, 2026
- Habits from nine teams, written into gstack. (#4585)
- Three more habits from teams that run evals. (#4602)
- The /ship conductor trial plan gives its real-problem judge one more attempt on fresh labels after it missed its agreement bar twice, and stops the trial incomplete if it misses again (GST-3003). (#4611)
- The /ship conductor trial plan now stops a trial only at the final remote-gate refusal, gives both arms the same note that the brief overrides team rules, and counts every report the no-gstack arm returns (GST-3003). (#4609)
- The /ship conductor trial plan now ends a trial at the remote gate when its case base isn't main, gives the no-gstack arm a test runner, and audits every trial for exposure to the plan (GST-3003). (#4605)
- The /ship conductor trial plan now runs an uncounted pilot in every arm before its counted trials and takes one planned look at half the cases (GST-3003). (#4587)
- gstack's own use on Capy can be counted, and is kept out of real-use numbers. (#4576)
- Free Tests shards finish closer together. (#4578)
- The weekly test-time recording can land again on its own. (#4581)
- The job-log tree.json step's recommended sleep is long enough for real runners. (#4589)
- Pull requests no longer wait on the Trunk flaky-test upload, and the quick tier's flaky passes now reach Trunk. (#4579)
- Windows Setup E2E finishes sooner on install changes. (#4575)
- Skills no longer stop on Codex when they clean up temp files. (#4612)
- /review on Codex with OpenAI models no longer holds back a review that ran its adversarial pass. (#4622)
- Crew threads on Capy now check in at 500M own tokens, standing threads rotate at 250M and any subagent past 50M gets a look, half the old lines, because Capy's token counts read about half what they did before 2026-11-15. (#4582)
- gstack no longer offers to add a `## Skill routing` section to your project's CLAUDE.md. (#4629)
- The README and docs no longer say gstack makes your agent fix more bugs. (#4598)
- `/eval-plan` now writes eval plans that waste less money. (#4591)
- /cso checks every folder above a source file before it looks at the file, so it never looks through a symlinked folder. (#4592)
- Plan reviews no longer read a /design-review audit summary as the branch's design doc. (#4623)
- Node's built-in test files now run with `node --test` in repos that use vitest or jest. (#4626)
- A quarantined test that the runner skipped now fails the run instead of passing it. (#4590)
- A flaky free test is fixed: the spawnSync overflow check no longer fails about once an hour on CI. (#4613)
- Free Tests runs its shards on 16-core runners. (#4600)
- /office-hours asks for ground truth first. (#4468)
- Every startup session ends with a dated test. (#4468)
- /plan-tune's dream cycle now logs each send of your typed answers to Anthropic. (#4621)
- Landing a ready PR no longer depends on a hand-copied gate decision, and the ready note, release PR and squash message say the right thing. (#4596)
- /ship no longer asks for a fresh review because of a stacked parent that main already had. (#4580)
- Results PRs with large captured agent sessions can be reviewed. (#4574)
- /ship no longer stalls on review notes a reviewer already cleared, counts review rounds the way the review policy reads them, and keeps security findings out of the PR body. (#4595)
- /ship's review readers are now told never to stop processes they didn't start. (#4607)
- /ship's review no longer stops when Capy's own drive sync database grows past 100 MB. (#4606)
- /ship's preflight now honors your repository's time limit for rerunning CI-skipped tests, and tells you when a fresh worktree needs its packages installed. (#4608)
- The slowest free test file is now six files. (#4588)
- Step 11.5 keeps a reviewed head current across base-only merges. (#4577)
- On a Capy install, only the owner's opt-in sends telemetry. (#4597)
- New page: working across agent systems. (#4583)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
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.

1 participant