Skip to content

fix(pregate): run Playwright specs with playwright test, not the unit runner - #3629

Closed
nfitzsimmons wants to merge 1 commit into
garrytan:mainfrom
nfitzsimmons:fix/pregate-playwright-runner
Closed

nfitzsimmons wants to merge 1 commit into
garrytan:mainfrom
nfitzsimmons:fix/pregate-playwright-runner

Conversation

@nfitzsimmons

Copy link
Copy Markdown
Contributor

Summary

In a repo that has Vitest unit tests and Playwright specs, gstack-pregate sends every changed JS/TS test file to the one detected runner. detectRunner returns npx vitest run {files} as soon as vitest is a dependency, so a diff that touches only Playwright specs runs:

ran: npx vitest run 'tests/e2e/home.spec.ts' 'tests/e2e/job-search.spec.ts' 'tests/e2e/panes.spec.ts'
No test files found, exiting with code 1
tests      lanes     fail    local lane exited 1 (? failed of ? ran; 3 files; pipefail) (PREGATE_LANE_FAILED)

Vitest's include filter matches none of the specs, so the lane fails even though the specs pass. A diff that also selects a unit test hides the bug, because Vitest then runs those files and drops the specs without a word. So most of the time the specs are skipped and nothing says so. When a diff touches only specs, /ship can't publish a pregate record.

With this change, a JS/TS test that imports @playwright/test gets its own group, run as playwright test from its nearest package, through the same package manager the nested-package runner uses (npx, pnpm exec, yarn, bun x). Other tests keep their runner. A declared runner still takes every file. A package manager missing from PATH leaves the spec unclaimed and names it, the same as the nested vitest path.

parseSummary also learns Playwright's summary. Playwright prints N failed, then the failed test names, then N passed, so the generic (N failed,)? N passed match counted every failure as zero. The parser now reads each count line on its own (failed, flaky, passed; skipped did not run), and only when the runner is playwright test.

Blast radius

The routing is in planRuns, and the summary parser runs only when the runner string contains playwright test. A repo with no test importing @playwright/test gets the same plan as before, and a declared runner skips the new branch entirely. The existing negative controls and nested-package tests still pass.

Tests

  • New planRuns case in test/pregate-selection.test.ts. The root has vitest; there is a root spec, a nested pnpm package with a vitest test, and a nested spec. Specs go to npx playwright test and pnpm exec playwright test, while the unit tests keep npx vitest run and pnpm exec vitest run. Also covered: a declared runner still takes the spec, and a missing pnpm leaves it unclaimed.
  • parseSummary gets two rows: a failed, flaky, skipped and passed run with names between the counts (ran: 138, failed: 2), and a clean run.
  • Both fail on main and pass with the fix. bun run typecheck is clean, and bun run typecheck:test reports no new diagnostics.
  • test/pregate-{selection,rust,dart,bats-nested,supervise}.test.ts: 87 pass, 8 fail. The same 8 fail on main without this change on my Mac (supervise progress adapters, the hang/timeout bin cases, and four gstack-pregate (bin) cases), so they look environment-dependent.
  • On the repo where I hit this (Electron + Vitest + Playwright, a diff touching only three specs), the fixed lane now runs npx playwright test on the three specs and passes: 121 tests ran in 3 file(s), exit 0.

Not covered: the planner doesn't build the app, so a Playwright project that needs a build before its specs, and has no webServer, still tests whatever build is on disk. Repos like that can declare a guards entry for their e2e script, as before.

🤖 Generated with Claude Code

… runner

In a repo whose unit runner is vitest (or jest, or bun), the lanes check sent
every changed JS/TS test to that runner, Playwright specs included. Vitest's
include filter matches none of them, so a diff that touches only Playwright
specs ran `npx vitest run tests/e2e/...`, printed "No test files found" and
failed the lane with exit 1. A diff that also selected unit tests hid it.

A JS/TS test that imports @playwright/test now plans its own group, run as
`playwright test` from its nearest package through that package's manager
(npx, pnpm exec, yarn, bun x). A declared runner still takes every file.
parseSummary reads Playwright's count lines (failed tests are listed between
them, so the generic `N failed, N passed` match missed the failures).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Oct 29, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thank you for this fix. A crew lane is picking it up, together with your related pregate PRs, to land on current main with Co-authored-by credit to you.

capy-ai Bot added a commit that referenced this pull request Nov 2, 2026
…s; literals stops flagging stray digits (#3598, #3492) (#3741)

* fix(pregate): runner detection for pytest, Playwright and mixed-language roots; literals binds one-character values

A missing pytest is PREGATE_ENVIRONMENT, not the diff's failure (#3598).
Playwright specs run under playwright test, with missing browsers reported
as the machine's gap (#3629). Root tests in two languages each get their
runner, and a repo's bun/vitest/jest claims only JS/TS (#3600). literals
counts a one-character old value only in a statement naming the constant,
and a call-site name also needs the module (#3492, gstack-evals#97).

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

* fix: pre-landing review fixes

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

* docs(pregate): name the import-type shapes the Playwright detection skips

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

* fix: escape Playwright file filters; skip type-only Playwright imports; pytest probe and summary read hardening

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

* fix(pregate): linear Playwright import scan; comments and no-space imports detected

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

* docs(pregate): Playwright missing-browsers exception and literals continuation rule

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>
@capy-ai

capy-ai Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thanks @nfitzsimmons. This landed in v1.93.15.0 as #3741: a spec that imports @playwright/test now runs under playwright test, and a run where no browser is installed reports PREGATE_ENVIRONMENT. The fix was rewritten on current main rather than merged from this branch (our policy for outside code), and the idea is credited in the changelog. Closing this PR in favor of that change.

@capy-ai capy-ai Bot closed this Nov 2, 2026
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