From 5d6ebd6e4a4df23495fc8570da514be596cce5df Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Sat, 11 Apr 2026 22:57:56 -0700 Subject: [PATCH] chore: migrate api-crash-reporter-spec.ts to vitest --- ...ter-spec.ts => api-crash-reporter.spec.ts} | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) rename spec/{api-crash-reporter-spec.ts => api-crash-reporter.spec.ts} (96%) diff --git a/spec/api-crash-reporter-spec.ts b/spec/api-crash-reporter.spec.ts similarity index 96% rename from spec/api-crash-reporter-spec.ts rename to spec/api-crash-reporter.spec.ts index c9a326c49b..f6ffa29b15 100644 --- a/spec/api-crash-reporter-spec.ts +++ b/spec/api-crash-reporter.spec.ts @@ -3,6 +3,7 @@ import { app } from 'electron/main'; import * as Busboy from 'busboy'; import { expect } from 'chai'; import * as uuid from 'uuid'; +import { describe, it } from 'vitest'; import * as childProcess from 'node:child_process'; import { EventEmitter } from 'node:events'; @@ -263,10 +264,9 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_ // Regression: base::circular_deque relocates elements on growth, // corrupting crashpad::Annotation's self-referential pointers and // causing missing crash keys or a hung handler. See crash_keys.cc. - it('does not corrupt the crashpad annotation list after deque reallocation', async function () { + it('does not corrupt the crashpad annotation list after deque reallocation', { timeout: 45000 }, async () => { // Tight timeout so a hanging handler fails fast instead of waiting - // for the mocha default of 120s. - this.timeout(45000); + // for the suite default. const { port, waitForCrash } = await startServer(); runCrashApp('renderer-dynamic-keys', port); const crash = await Promise.race([ @@ -330,20 +330,22 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_ }); describe('OOM crash keys', () => { - it('reports OOM stack trace and heap statistics when renderer runs out of memory', async function () { - this.timeout(120000); - const { port, waitForCrash } = await startServer(); - runCrashApp('renderer-oom', port, ['--js-flags=--max-old-space-size=128']); - const crash = await waitForCrash(); - expect(crash.process_type).to.equal('renderer'); - expect(crash['electron.v8-oom.stack']).to.be.a('string'); - expect(crash['electron.v8-oom.stack']).to.include('oomTrigger'); - expect(crash['electron.v8-oom.heap.used']).to.be.a('string'); - expect(crash['electron.v8-oom.heap.limit']).to.be.a('string'); - }); + it( + 'reports OOM stack trace and heap statistics when renderer runs out of memory', + { timeout: 120000 }, + async () => { + const { port, waitForCrash } = await startServer(); + runCrashApp('renderer-oom', port, ['--js-flags=--max-old-space-size=128']); + const crash = await waitForCrash(); + expect(crash.process_type).to.equal('renderer'); + expect(crash['electron.v8-oom.stack']).to.be.a('string'); + expect(crash['electron.v8-oom.stack']).to.include('oomTrigger'); + expect(crash['electron.v8-oom.heap.used']).to.be.a('string'); + expect(crash['electron.v8-oom.heap.limit']).to.be.a('string'); + } + ); - it('captures the calling function on JSON.stringify OOM', async function () { - this.timeout(120000); + it('captures the calling function on JSON.stringify OOM', { timeout: 120000 }, async () => { const { port, waitForCrash } = await startServer(); runCrashApp('renderer-oom-json', port, ['--js-flags=--max-old-space-size=128']); const crash = await waitForCrash(); @@ -352,8 +354,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_ expect(crash['electron.v8-oom.stack']).to.include('serializeData'); }); - it('captures OOM crash keys inside a web worker', async function () { - this.timeout(120000); + it('captures OOM crash keys inside a web worker', { timeout: 120000 }, async () => { const { port, waitForCrash } = await startServer(); runCrashApp('renderer-oom-worker', port, ['--js-flags=--max-old-space-size=128']); const crash = await waitForCrash();