Skip to content

test: prepare the spec suite for a parallel runner (45-x-y) - #54282

Merged
MarshallOfSound merged 1 commit into
45-x-yfrom
bp/45-x-y/spec-parallel-prep
Sep 24, 2026
Merged

MarshallOfSound merged 1 commit into
45-x-yfrom
bp/45-x-y/spec-parallel-prep

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Backport of #54261

See that PR for details. The BaseWindow spec does not exist on this branch, so its part is dropped.

Notes: none

* test: use describe() for spec groups that were declared with it()

A few BrowserWindow spec groups were declared with it()/ifit() but only
contain further it() calls. Mocha registered the inner tests against a
suite that had already started, so they never ran; vitest rejects the
nesting outright. Declare them as suites.

Some of the tests this brings back to life no longer match macOS: a
non-resizable window is not maximizable there, and maximizable on its own
follows fullScreenable because the zoom button doubles as the full screen
button (NativeWindowMac::UpdateZoomButton), so those expectations are
updated or kept to Windows; representedFilename comes back as an absolute
path, so the spec sets one; and the animated setBounds()/setSize()
'resized' event does not arrive on the CI hosts, so that pair stays
skipped with a FIXME.

* test: set retries on the suite instead of inside the running test

this.retries(n) from inside a test body only works in mocha, which reads
the value after the attempt fails. Move the two remaining uses up to the
enclosing describe so the retry count is known when the test is
declared.

* test: keep running defer()-ed cleanups after one of them throws

runCleanupFunctions() stopped at the first cleanup that threw and never
cleared the list, so the same stale cleanup ran, and threw, again after
every later test in the file. Drain the list up front, run every entry,
and report the collected errors once.

* test: accept an options argument between the title and body of describe/it

Lets specs write it(title, { timeout, retry, tags }, fn) and
describe(title, { ... }, fn). timeout and retry map onto mocha's per
runnable settings; tags are ignored by the mocha runner and are there so
suites can be marked for the upcoming parallel runner without a second
syntax.

* test: only reap windows that were open when closeWindow() was called

closeWindow() checks on the next tick that no other windows were left
behind and destroys any it finds. It re-read the window list at that
point, so when the next test had already created its window by then, that
window was destroyed too and the test failed with 'Object has been
destroyed'. Whether that happened depended only on how long the runner
took between afterEach and the next beforeEach.

* test: don't count unrelated webContents in the WebContentsView reuse spec

The test compared getAllWebContents().length before and after, which also
counts webContents that earlier tests left to the garbage collector and
that can be collected while this test awaits a load. Compare the sets
instead.

* test: tag the suites that need the machine to themselves as serial

Suites that depend on OS-level window focus, the system clipboard, screen
capture, global shortcuts, real mouse input or the mocked D-Bus services
cannot share the machine with other test windows. Mark them with
{ tags: ['serial'] } so a parallel runner can hold them back and run them
one at a time; the mocha runner ignores the option.

* test: don't pick up another window's visibilitychange message

The document.visibilityState specs listened for 'pong' on ipcMain, so a
late message from the previous test's page (sent as its window was torn
down) could be taken for the first report of the new window. Listen on
the window's own webContents.ipc instead.

The BrowserView variant counted visibilitychange events from page load,
which includes the freshly shown host window becoming visible when that
reaches the renderer after the load; wait for the page to report
'visible' before counting.

* test: clear the logind mock's call log before the powerMonitor specs

The specs assert exact Inhibit call counts on the python-dbusmock logind
object. That mock is started once around the whole test run, so any other
Electron process of the same run that engaged powerMonitor has already
left calls in its log. Clear it before counting.

* test: wait for focus before blurring in the BrowserWindow.focus() spec

'focuses a blurred window' called blur() straight after show(). blur()
does nothing to a window that has not become key yet, and for the first
window a process shows on macOS that trails the 'show' event, so the
'blur' the test then waited for never came. Wait for 'focus' first, as
the BrowserWindow.blur() spec next to it already does.

* test: give the utilityProcess heap snapshot spec a minute

Growing the heap to its limit and writing the snapshot is CPU bound and
does not fit in the default 30 seconds on the macOS x64 CI hosts when
other spec files run alongside it.

(cherry picked from commit 5c34ec5)
@trop trop Bot mentioned this pull request Sep 24, 2026
5 tasks done
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 24, 2026 07:01
@MarshallOfSound
MarshallOfSound merged commit 8257fac into 45-x-y Sep 24, 2026
89 checks passed
@MarshallOfSound
MarshallOfSound deleted the bp/45-x-y/spec-parallel-prep branch September 24, 2026 07:59
@release-clerk

release-clerk Bot commented Sep 24, 2026

Copy link
Copy Markdown

No Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants