From be43c266e06812b692cd09e8eff5b1c7e84ee367 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 31 Jan 2026 10:33:50 +0000 Subject: [PATCH] fix(test): resolve hangs in multiple unit tests and harden runner Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- ONBOARDING_REPORT.md | 7 +++++++ scripts/run-unit-tests.mjs | 2 ++ tests/nostr-service-access-control.test.mjs | 2 ++ 3 files changed, 11 insertions(+) diff --git a/ONBOARDING_REPORT.md b/ONBOARDING_REPORT.md index 3e109e05..8076bd6b 100644 --- a/ONBOARDING_REPORT.md +++ b/ONBOARDING_REPORT.md @@ -26,6 +26,13 @@ 4. **`tests/nostr-send-direct-message.test.mjs`**: Susceptible to similar hangs. * **Fix Applied**: Added `after(() => setTimeout(() => process.exit(0), 100))` to force exit. +5. **`tests/nostr-service-access-control.test.mjs`**: Caused hangs due to mock tool cleanup. + * **Fix Applied**: Added `setTimeout(() => process.exit(0), 100)` in `after` hook. + +### Test Runner Robustness + +* **`scripts/run-unit-tests.mjs`**: Updated to explicitly call `process.exit(0)` upon successful completion of all tests. This acts as a global safeguard against lingering open handles (e.g., from `nostr-tools` relays or timers) causing CI timeouts. + ### Browserslist Warning The build command emitted: `Browserslist: caniuse-lite is outdated`. diff --git a/scripts/run-unit-tests.mjs b/scripts/run-unit-tests.mjs index 6f3caf4c..f6f10ccc 100755 --- a/scripts/run-unit-tests.mjs +++ b/scripts/run-unit-tests.mjs @@ -178,6 +178,8 @@ async function run() { } console.log("\n✔ All unit tests passed"); + // Force exit to ensure we don't hang on lingering handles/timers + process.exit(0); } try { diff --git a/tests/nostr-service-access-control.test.mjs b/tests/nostr-service-access-control.test.mjs index c6bb06fb..0ab4220c 100644 --- a/tests/nostr-service-access-control.test.mjs +++ b/tests/nostr-service-access-control.test.mjs @@ -67,6 +67,8 @@ test.after(() => { } else { globalThis.NostrTools = originalGlobalNostrTools; } + + setTimeout(() => process.exit(0), 100); }); function createServiceWithAccessControl() {