/** * Avoid `UnhandledPromiseRejectionWarning` if a promise fails before we `await` it. * @example * ```javascript * const emailPromise = catchLater(getMail(...)); * await ... * const email = await emailPromise; * ``` * @param {Promise} promise A promise to ignore for now (will be caught later) */ export function catchLater(promise: Promise): Promise; /** * Attach a custom error message if a promise fails. * If the promise succeeds, this function does nothing. * * @example * ```javascript * const page = newPage(config); * await page.goto('https://example.org/'); * await customErrorMessage( * page.waitForSelector('blink'), ' element not found (BUG-123)'); * await closePage(page); * ``` * @param {Promise} promise The promise to wait for. * @param {string} message Custom message to attach to the error; */ export function customErrorMessage(promise: Promise, message: string): Promise; /** * Mark a code section as expected to fail. * If the async function throws an error, the error will be included in reports, but not counted as a test failure. * If the async function succeeds, a warning will be printed. * * @example * ``` * await expectedToFail(config, 'BUG-1234', async() => { * ... * }, { * expectNothing: config.env === 'very-good-environment', * }); * ``` * @param {*} config The pentf configuration. * @param {string} message Error message to show when the section fails (recommended: ticket URL) * @param {() => any} asyncFunc The asynchronous section which is part of the test. * @param {{expectNothing?: boolean}} __namedParameters Options (currently not visible in output due to typedoc bug) * @param {boolean} expectNothing Do nothing – this is convenient if the code is expected to work on some environments. (default: false) */ export function expectedToFail(config: any, message: string, asyncFunc: () => any, { expectNothing }?: { expectNothing?: boolean; }): Promise; /** * Raise an error if a promise does not finish within a certain timeframe. * Note this does not cancel the promise itself (because that's impossible). * * @param {*} config The pentf configuration. * @param {Promise} promise The promise to limit * @param {{expectNothing?: boolean, timeout?: number, warning?: number, message?: string}} __namedParameters Options (currently not visible in output due to typedoc bug) * @param {number} timeout Timeout in ms (by default 10000=10s) * @param {string} message Optional error message to show when the timeout fires. * @param {boolean} warning Only print an error message, do not throw. * @returns {*} Whatever the promise returned, if it is successful */ export function timeoutPromise(config: any, promise: Promise, { timeout, message, warning }?: { expectNothing?: boolean; timeout?: number; warning?: number; message?: string; }): any;