Skip to content

Commit a678b7a

Browse files
authored
chore(e2e): abort waitUntil when test run is aborted (#7551)
1 parent 8f38cbe commit a678b7a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/compass-e2e-tests/helpers/compass.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
import treeKill from 'tree-kill';
4444
import { downloadPath } from './downloads';
4545
import path from 'path';
46+
import { globalFixturesAbortController } from './test-runner-global-fixtures';
4647

4748
const killAsync = async (pid: number, signal?: string) => {
4849
return new Promise<void>((resolve, reject) => {
@@ -178,6 +179,27 @@ export class Compass {
178179
});
179180
}
180181

182+
// The waitUntil helper will continue running even if we started tests
183+
// teardown on abort. To work around that, we will override the default
184+
// method, will short circuit the wait if we aborted, and then throw the
185+
// error instead of returning the result
186+
browser.overwriteCommand(
187+
'waitUntil',
188+
async function (origWaitUntil, condition, options) {
189+
// eslint-disable-next-line @typescript-eslint/await-thenable
190+
const result = await origWaitUntil(function () {
191+
if (globalFixturesAbortController.signal.aborted) {
192+
return true;
193+
}
194+
return condition();
195+
}, options);
196+
if (globalFixturesAbortController.signal.aborted) {
197+
throw new Error('Test run was aborted');
198+
}
199+
return result;
200+
}
201+
);
202+
181203
this.addDebugger();
182204
}
183205

0 commit comments

Comments
 (0)