From bc6ff78f339723fbe193cc7e6d287e0c70448953 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Wed, 27 Aug 2025 15:23:42 -0700 Subject: [PATCH] test: use 120s timeout globally --- package.json | 3 --- test/packager.spec.ts | 60 +++++++++++++++++++------------------------ vitest.config.ts | 2 +- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 1f86471e..8fadd17d 100644 --- a/package.json +++ b/package.json @@ -97,9 +97,6 @@ "bundler", "app" ], - "ava": { - "timeout": "120s" - }, "funding": { "url": "https://github.com/electron/packager?sponsor=1" }, diff --git a/test/packager.spec.ts b/test/packager.spec.ts index 3d2af6ff..bcc3225f 100644 --- a/test/packager.spec.ts +++ b/test/packager.spec.ts @@ -125,37 +125,33 @@ describe('packager', () => { ); }); - it( - 'can overwrite older packages', - { timeout: 30_000 }, // double the timeout because we have two full packager runs - async ({ baseOpts }) => { - const opts: Options = { - ...baseOpts, - }; + it('can overwrite older packages', async ({ baseOpts }) => { + const opts: Options = { + ...baseOpts, + }; - const paths = await packager(opts); - expect(paths).toHaveLength(1); - expect(paths[0]).toEqual( - path.join( - opts.out!, - generateFinalBasename({ - name: opts.name, - platform: process.platform, - arch: getHostArch(), - }), - ), - ); - // Create a dummy file to detect whether the output directory is replaced in subsequent runs - const testPath = path.join(paths[0], 'test.txt'); - await fs.writeFile(testPath, 'test'); - // Second run without overwrite should be skipped - await packager(opts); - expect(fs.existsSync(testPath)).toBe(true); - // Third run with overwrite should replace the output directory - await packager({ ...opts, overwrite: true }); - expect(fs.existsSync(testPath)).toBe(false); - }, - ); + const paths = await packager(opts); + expect(paths).toHaveLength(1); + expect(paths[0]).toEqual( + path.join( + opts.out!, + generateFinalBasename({ + name: opts.name, + platform: process.platform, + arch: getHostArch(), + }), + ), + ); + // Create a dummy file to detect whether the output directory is replaced in subsequent runs + const testPath = path.join(paths[0], 'test.txt'); + await fs.writeFile(testPath, 'test'); + // Second run without overwrite should be skipped + await packager(opts); + expect(fs.existsSync(testPath)).toBe(true); + // Third run with overwrite should replace the output directory + await packager({ ...opts, overwrite: true }); + expect(fs.existsSync(testPath)).toBe(false); + }); it('defaults the out directory to the current working directory', async ({ baseOpts, @@ -235,7 +231,6 @@ describe('packager', () => { // FIXME: This flakes with ENOTEMPTY: directory not empty it.runIf(process.platform === 'darwin').skip( 'can package for all target platforms at once', - { timeout: 120_000 }, async ({ baseOpts }) => { const opts: Options = { ...baseOpts, @@ -264,7 +259,6 @@ describe('packager', () => { it.runIf(process.platform !== 'darwin')( 'can package for all target platforms at once (no universal on non-darwin)', - { timeout: 120_000 }, async ({ baseOpts }) => { const opts: Options = { ...baseOpts, @@ -1368,7 +1362,7 @@ describe('packager', () => { }); describe('codesign', () => { - it('can sign the app', { timeout: 60_000 }, async ({ baseOpts }) => { + it('can sign the app', async ({ baseOpts }) => { const opts: Options = { ...baseOpts, osxSign: { identity: 'codesign.electronjs.org' }, diff --git a/vitest.config.ts b/vitest.config.ts index 7f7b48b8..8e8b5357 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,7 +5,7 @@ export default defineConfig({ setupFiles: ['./test/vitest.setup.ts'], include: ['./test/**/*.spec.ts'], clearMocks: true, - testTimeout: 15_000, + testTimeout: 120_000, typecheck: { tsconfig: './tsconfig.json', },