Skip to content

test: run the spec suite with vitest - #54264

Merged
MarshallOfSound merged 2 commits into
mainfrom
claude/project-thread-a1ddk9-vitest
Sep 26, 2026
Merged

MarshallOfSound merged 2 commits into
mainfrom
claude/project-thread-a1ddk9-vitest

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Runs the spec suite with vitest instead of the in-process mocha runner. The vitest CLI starts a pool of electron spec/ processes, gives each one spec file at a time, and runs the suites tagged serial on their own afterwards. Spec files are unchanged: they are still loaded by Electron's own Node.js (no Vite transform) and keep mocha's describe/it/before/after/this.timeout() interface via a small compatibility layer. npm test, --files, -g, the JUnit report, the CI rerun step and spec-timings.json work as before; mocha and its reporters are removed.

"Run Electron Tests" step, this PR vs #54261 (same base, mocha):

Leg (shards) mocha vitest
linux-x64 5 / 4 / 4 min 4 / 4 / 3
linux-arm64 7 / 6 / 5 5 / 5 / 3
linux-x64 asan, ubsan 14 / 11 / 13, 7 / 5 / 6 11 / 11 / 11, 6 / 6 / 4
windows-x64, arm64 13 / 8, 15 / 23 10 / 8, 11 / 19
macos-arm64 darwin, mas 15 / 18, 16 15 / 17, 14
macos-x64 darwin, mas 28, 23 21, 14

The pool sizes itself to about a third of the runner's CPUs (2 on the 4-core Linux/Windows hosts, 4 on macOS x64), so the gain on CI is bounded by the runners; on a 64-core machine the whole Linux suite runs in under 6 minutes against 20.

The asan numbers need #54296 (now on main): before it api-clipboard.spec.ts waited for an unrelated main-loop wake on every read and the first asan shard ran past the 60 min job limit.

Checklist

Release Notes

Notes: none

@socket-security

socket-security Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedvitest@​5.0.1981007998100
Addedvite@​8.3.0991008297100

View full report

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@claude review

@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch 2 times, most recently from 518f9f2 to 8dded97 Compare September 24, 2026 00:53

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread spec/vitest/mocha-compat.ts Resolved
Comment thread spec/vitest.config.ts Resolved
Comment thread spec/vitest.config.ts Resolved
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9 branch from b21b648 to 50e806f Compare September 24, 2026 01:37
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch from 8dded97 to 6e64e49 Compare September 24, 2026 01:37
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9 branch from 50e806f to 0eaffe5 Compare September 24, 2026 03:20
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch 3 times, most recently from 17ff6c7 to ad8f2d1 Compare September 24, 2026 04:07
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9 branch from 0eaffe5 to 5f101b5 Compare September 24, 2026 05:14
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch 2 times, most recently from 31c307e to 85f8bba Compare September 24, 2026 06:38
Base automatically changed from claude/project-thread-a1ddk9 to main September 24, 2026 06:55
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch 2 times, most recently from f93e99b to 6ecc14e Compare September 24, 2026 07:03
@MarshallOfSound MarshallOfSound added target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 24, 2026
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch from 6ecc14e to 44b4f95 Compare September 24, 2026 07:26
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch from 7e4a2c1 to f668b96 Compare September 24, 2026 11:01
@MarshallOfSound
MarshallOfSound changed the base branch from main to fix/settle-promise-outside-task September 24, 2026 11:01
Base automatically changed from fix/settle-promise-outside-task to main September 24, 2026 18:42
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 24, 2026 19:07
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch from f668b96 to 61a1441 Compare September 24, 2026 21:12
@trop trop Bot added in-flight/44-x-y in-flight/43-x-y in-flight/42-x-y and removed target/43-x-y PR should also be added to the "43-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Sep 25, 2026
Replace the in-process mocha runner with vitest driving a pool of Electron
processes.

- spec/vitest/electron-pool.ts is a vitest pool whose workers are
  'electron spec/ --vitest-worker' browser processes talking to the CLI
  over a Node IPC channel (JSON, see ipc-serialization.ts, because the
  host Node cannot read Electron's newer V8 wire format).
- spec/index.js keeps the pre-ready process setup and then hands the main
  process to vitest's worker runtime (spec/vitest/worker.ts).
  experimental.viteModuleRunner is off, so spec files are imported by
  Electron's own Node exactly as before (native ESM, type stripping, no
  Vite transform).
- spec/vitest/mocha-compat.ts provides mocha's BDD globals (describe/it/
  before/after, this.timeout()/this.skip(), done callbacks, resettable
  timeouts, hooks in declaration order, a macrotask between runnables) on
  top of vitest, so the spec files run unchanged.
- Two projects run in sequence: everything not tagged 'serial' across
  several workers, then the 'serial' suites one file at a time.
- script/spec-runner.js translates --files/-g into vitest filters, wraps
  the CLI in dbus_mock.py on Linux and reruns failures from vitest's JUnit
  report; leftover Electron processes are killed once per run
  (global-setup.js) and per worker process group.
- spec-timings.json for shard balancing comes from timings-reporter.ts;
  mocha, its reporters and ELECTRON_FORCE_TEST_SUITE_EXIT are gone.
app.isActive(), app.hide()/show() and the dock are machine-wide state, so
these suites cannot share the screen with other spec processes. The
isActive spec also assumed the process starts out inactive, which a
freshly launched worker on the CI hosts is not; hide first in that case.
@MarshallOfSound
MarshallOfSound force-pushed the claude/project-thread-a1ddk9-vitest branch from 5fd0fad to 4d06682 Compare September 25, 2026 22:03
@MarshallOfSound
MarshallOfSound merged commit 32b93bf into main Sep 26, 2026
72 checks passed
@MarshallOfSound
MarshallOfSound deleted the claude/project-thread-a1ddk9-vitest branch September 26, 2026 00:20
@release-clerk

release-clerk Bot commented Sep 26, 2026

Copy link
Copy Markdown

No Release Notes

@trop trop Bot added merged/45-x-y PR was merged to the "45-x-y" branch. and removed in-flight/45-x-y labels Sep 26, 2026
@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/44-x-y in-flight/43-x-y in-flight/42-x-y labels Sep 26, 2026
MarshallOfSound pushed a commit that referenced this pull request Oct 15, 2026
…ws or hangs (#54950)

* test: run every afterEach hook and deferred cleanup when one throws

vitest runs a test's afterEach hooks one at a time and stops at the
first one that throws,
skipping the rest of that suite's hooks and every enclosing suite's.
The spec runner adds defer()-ed cleanup as the first afterEach hook of
every suite,
so a single failing cleanup also skipped hooks such as
protocol.unhandle() and closeWindow().
The handler and the window then leaked,
and on CI the next try failed in beforeEach
with "Failed to register protocol: no-cors".

The runner now catches what each afterEach hook throws,
defer()-ed cleanup included,
lets the remaining hooks run,
and rethrows the errors from an onTestFinished callback
once all of them have finished.
The test still fails, and vitest reports each error separately.
The order of hooks and cleanups is unchanged.
A new spec covers failing hooks and cleanups in nested suites.

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

* test: give each deferred cleanup the hook timeout

defer()-ed cleanup has had no timeout since the move to vitest (#54264).
The mocha shim registered it with vitest's hook timeout set to 0,
which vitest treats as no timeout,
and the runner from #54439 puts it into each suite's afterEach hooks
directly, not through afterEach().
So a cleanup that never settles,
such as a closeWindow() whose window never emits 'closed',
hangs the spec file until the CI job times out
instead of failing one test.

Each defer()-ed cleanup now gets the hook timeout,
as an afterEach hook would.
A cleanup that times out fails the test with an error whose stack
points at its defer() call,
and the cleanups registered before it and the remaining afterEach hooks
still run.
The timeout is read when the cleanup runs, so vi.setConfig() applies;
the new spec uses that to keep its slow-cleanup case fast.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
MarshallOfSound pushed a commit that referenced this pull request Oct 15, 2026
…ws or hangs (#54997)

* test: run every afterEach hook and deferred cleanup when one throws

vitest runs a test's afterEach hooks one at a time and stops at the
first one that throws,
skipping the rest of that suite's hooks and every enclosing suite's.
The spec runner adds defer()-ed cleanup as the first afterEach hook of
every suite,
so a single failing cleanup also skipped hooks such as
protocol.unhandle() and closeWindow().
The handler and the window then leaked,
and on CI the next try failed in beforeEach
with "Failed to register protocol: no-cors".

The runner now catches what each afterEach hook throws,
defer()-ed cleanup included,
lets the remaining hooks run,
and rethrows the errors from an onTestFinished callback
once all of them have finished.
The test still fails, and vitest reports each error separately.
The order of hooks and cleanups is unchanged.
A new spec covers failing hooks and cleanups in nested suites.

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

Co-authored-by: Charles Kerr <[email protected]>

* test: give each deferred cleanup the hook timeout

defer()-ed cleanup has had no timeout since the move to vitest (#54264).
The mocha shim registered it with vitest's hook timeout set to 0,
which vitest treats as no timeout,
and the runner from #54439 puts it into each suite's afterEach hooks
directly, not through afterEach().
So a cleanup that never settles,
such as a closeWindow() whose window never emits 'closed',
hangs the spec file until the CI job times out
instead of failing one test.

Each defer()-ed cleanup now gets the hook timeout,
as an afterEach hook would.
A cleanup that times out fails the test with an error whose stack
points at its defer() call,
and the cleanups registered before it and the remaining afterEach hooks
still run.
The timeout is read when the cleanup runs, so vi.setConfig() applies;
the new spec uses that to keep its slow-cleanup case fast.

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

Co-authored-by: Charles Kerr <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <[email protected]>
MarshallOfSound pushed a commit that referenced this pull request Oct 15, 2026
…ws or hangs (#54994)

* test: run every afterEach hook and deferred cleanup when one throws

vitest runs a test's afterEach hooks one at a time and stops at the
first one that throws,
skipping the rest of that suite's hooks and every enclosing suite's.
The spec runner adds defer()-ed cleanup as the first afterEach hook of
every suite,
so a single failing cleanup also skipped hooks such as
protocol.unhandle() and closeWindow().
The handler and the window then leaked,
and on CI the next try failed in beforeEach
with "Failed to register protocol: no-cors".

The runner now catches what each afterEach hook throws,
defer()-ed cleanup included,
lets the remaining hooks run,
and rethrows the errors from an onTestFinished callback
once all of them have finished.
The test still fails, and vitest reports each error separately.
The order of hooks and cleanups is unchanged.
A new spec covers failing hooks and cleanups in nested suites.

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

Co-authored-by: Charles Kerr <[email protected]>

* test: give each deferred cleanup the hook timeout

defer()-ed cleanup has had no timeout since the move to vitest (#54264).
The mocha shim registered it with vitest's hook timeout set to 0,
which vitest treats as no timeout,
and the runner from #54439 puts it into each suite's afterEach hooks
directly, not through afterEach().
So a cleanup that never settles,
such as a closeWindow() whose window never emits 'closed',
hangs the spec file until the CI job times out
instead of failing one test.

Each defer()-ed cleanup now gets the hook timeout,
as an afterEach hook would.
A cleanup that times out fails the test with an error whose stack
points at its defer() call,
and the cleanups registered before it and the remaining afterEach hooks
still run.
The timeout is read when the cleanup runs, so vi.setConfig() applies;
the new spec uses that to keep its slow-cleanup case fast.

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

Co-authored-by: Charles Kerr <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <[email protected]>
MarshallOfSound pushed a commit that referenced this pull request Oct 15, 2026
…ws or hangs (#54995)

* test: run every afterEach hook and deferred cleanup when one throws

vitest runs a test's afterEach hooks one at a time and stops at the
first one that throws,
skipping the rest of that suite's hooks and every enclosing suite's.
The spec runner adds defer()-ed cleanup as the first afterEach hook of
every suite,
so a single failing cleanup also skipped hooks such as
protocol.unhandle() and closeWindow().
The handler and the window then leaked,
and on CI the next try failed in beforeEach
with "Failed to register protocol: no-cors".

The runner now catches what each afterEach hook throws,
defer()-ed cleanup included,
lets the remaining hooks run,
and rethrows the errors from an onTestFinished callback
once all of them have finished.
The test still fails, and vitest reports each error separately.
The order of hooks and cleanups is unchanged.
A new spec covers failing hooks and cleanups in nested suites.

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

Co-authored-by: Charles Kerr <[email protected]>

* test: give each deferred cleanup the hook timeout

defer()-ed cleanup has had no timeout since the move to vitest (#54264).
The mocha shim registered it with vitest's hook timeout set to 0,
which vitest treats as no timeout,
and the runner from #54439 puts it into each suite's afterEach hooks
directly, not through afterEach().
So a cleanup that never settles,
such as a closeWindow() whose window never emits 'closed',
hangs the spec file until the CI job times out
instead of failing one test.

Each defer()-ed cleanup now gets the hook timeout,
as an afterEach hook would.
A cleanup that times out fails the test with an error whose stack
points at its defer() call,
and the cleanups registered before it and the remaining afterEach hooks
still run.
The timeout is read when the cleanup runs, so vi.setConfig() applies;
the new spec uses that to keep its slow-cleanup case fast.

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

Co-authored-by: Charles Kerr <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/none

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants