From 2e142036b410241e5d3e196de5cadbf8a84e7117 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Tue, 11 Nov 2025 10:54:08 +0100 Subject: [PATCH] chore(e2e): abort waitUntil when test run is aborted --- packages/compass-e2e-tests/helpers/compass.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/compass-e2e-tests/helpers/compass.ts b/packages/compass-e2e-tests/helpers/compass.ts index 42227ad9562..389c78974f9 100644 --- a/packages/compass-e2e-tests/helpers/compass.ts +++ b/packages/compass-e2e-tests/helpers/compass.ts @@ -43,6 +43,7 @@ import { import treeKill from 'tree-kill'; import { downloadPath } from './downloads'; import path from 'path'; +import { globalFixturesAbortController } from './test-runner-global-fixtures'; const killAsync = async (pid: number, signal?: string) => { return new Promise((resolve, reject) => { @@ -178,6 +179,27 @@ export class Compass { }); } + // The waitUntil helper will continue running even if we started tests + // teardown on abort. To work around that, we will override the default + // method, will short circuit the wait if we aborted, and then throw the + // error instead of returning the result + browser.overwriteCommand( + 'waitUntil', + async function (origWaitUntil, condition, options) { + // eslint-disable-next-line @typescript-eslint/await-thenable + const result = await origWaitUntil(function () { + if (globalFixturesAbortController.signal.aborted) { + return true; + } + return condition(); + }, options); + if (globalFixturesAbortController.signal.aborted) { + throw new Error('Test run was aborted'); + } + return result; + } + ); + this.addDebugger(); }