Merge branch 'master' into feat/2714-start-server-on-integration-tests

This commit is contained in:
Bruno Ribeiro
2021-04-06 17:34:01 +01:00
committed by GitHub
2 changed files with 10 additions and 3 deletions
+9 -2
View File
@@ -6,8 +6,9 @@
import * as playwright from 'playwright';
import deepEqual = require('deep-equal');
import { ITerminalOptions } from 'xterm';
import { deepStrictEqual, fail } from 'assert';
export async function pollFor<T>(page: playwright.Page, evalOrFn: string | (() => Promise<T>), val: T, preFn?: () => Promise<void>): Promise<void> {
export async function pollFor<T>(page: playwright.Page, evalOrFn: string | (() => Promise<T>), val: T, preFn?: () => Promise<void>, maxDuration?: number): Promise<void> {
if (preFn) {
await preFn();
}
@@ -18,8 +19,14 @@ export async function pollFor<T>(page: playwright.Page, evalOrFn: string | (() =
}
if (!deepEqual(result, val)) {
if (maxDuration === undefined) {
maxDuration = 2000;
}
if (maxDuration <= 0) {
deepStrictEqual(result, val, 'pollFor max duration exceeded');
}
return new Promise<void>(r => {
setTimeout(() => r(pollFor(page, evalOrFn, val, preFn)), 1);
setTimeout(() => r(pollFor(page, evalOrFn, val, preFn, maxDuration! - 10)), 10);
});
}
}
+1 -1
View File
@@ -713,7 +713,7 @@ declare module 'xterm' {
* Adds an event listener for when the bell is triggered.
* @returns an `IDisposable` to stop listening.
*/
onBell: IEvent<void>;
onBell: IEvent<void>;
/**
* Unfocus the terminal.