mirror of
https://github.com/electron/electron.git
synced 2026-10-28 11:44:46 +08:00
* 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>