diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts index f36d2830..2b1e8828 100644 --- a/test/api/TestUtils.ts +++ b/test/api/TestUtils.ts @@ -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(page: playwright.Page, evalOrFn: string | (() => Promise), val: T, preFn?: () => Promise): Promise { +export async function pollFor(page: playwright.Page, evalOrFn: string | (() => Promise), val: T, preFn?: () => Promise, maxDuration?: number): Promise { if (preFn) { await preFn(); } @@ -18,8 +19,14 @@ export async function pollFor(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(r => { - setTimeout(() => r(pollFor(page, evalOrFn, val, preFn)), 1); + setTimeout(() => r(pollFor(page, evalOrFn, val, preFn, maxDuration! - 10)), 10); }); } } diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index b1995bb2..6bfb71ae 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -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; + onBell: IEvent; /** * Unfocus the terminal.