From 0aacfb91abff336e1cd53721cf97f33aeedea018 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Wed, 21 Jan 2026 21:36:24 +0800 Subject: [PATCH] Remove AfterAll hook and add --exit to e2e tests Eliminates the AfterAll hook that forced process exit in cleanup.ts to prevent hanging after tests. Adds the --exit flag to the cucumber-js command in the e2e test script to ensure proper test process termination. --- features/stepDefinitions/cleanup.ts | 12 +----------- package.json | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/features/stepDefinitions/cleanup.ts b/features/stepDefinitions/cleanup.ts index bb35df59..f4f64daf 100644 --- a/features/stepDefinitions/cleanup.ts +++ b/features/stepDefinitions/cleanup.ts @@ -1,4 +1,4 @@ -import { After, AfterAll, Before } from '@cucumber/cucumber'; +import { After, Before } from '@cucumber/cucumber'; import fs from 'fs-extra'; import path from 'path'; import { makeSlugPath } from '../supports/paths'; @@ -128,13 +128,3 @@ After(async function(this: ApplicationWorld, { pickle }) { // Scenario-specific logs are already in the right place, no need to move them }); - -// Force exit after all tests complete to prevent hanging -AfterAll({ timeout: 5000 }, async function() { - // Give a short grace period for any final cleanup - await new Promise((resolve) => setTimeout(resolve, 1000)); - - // Force exit the process - // This is necessary because sometimes Electron/Playwright resources don't fully clean up - process.exit(0); -}); diff --git a/package.json b/package.json index 53dd5ec5..74b23d6e 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test:unit": "cross-env ELECTRON_RUN_AS_NODE=1 ./node_modules/.bin/electron --max-old-space-size=8192 ./node_modules/vitest/vitest.mjs run", "test:unit:coverage": "pnpm run test:unit --coverage", "test:prepare-e2e": "cross-env READ_DOC_BEFORE_USING='docs/Testing.md' && pnpm run clean && pnpm run build:plugin && cross-env NODE_ENV=test DEBUG=electron-forge:* electron-forge package", - "test:e2e": "rimraf -- ./test-artifacts && cross-env NODE_ENV=test tsx scripts/developmentMkdir.ts && cross-env NODE_ENV=test cucumber-js --config features/cucumber.config.js", + "test:e2e": "rimraf -- ./test-artifacts && cross-env NODE_ENV=test tsx scripts/developmentMkdir.ts && cross-env NODE_ENV=test cucumber-js --config features/cucumber.config.js --exit", "test:manual-e2e": "pnpm exec cross-env NODE_ENV=test tsx ./scripts/start-e2e-app.ts", "make": "pnpm run build:plugin && cross-env NODE_ENV=production electron-forge make", "make:analyze": "cross-env ANALYZE=true pnpm run make",