lib/core/seleniumRunner.js
async function timeout(promise, ms, errorMessage) {
  let timer = null;

  return Promise.race([
    new Promise((resolve, reject) => {
      timer = setTimeout(reject, ms, new BrowserError(errorMessage));
      return timer;
    }),
    promise.then(value => {
      clearTimeout(timer);
      return value;
    })
  ]);
}
async function timeout(promise, ms, errorMessage) {
  let timer = null;

  return Promise.race([
    new Promise((resolve, reject) => {
      timer = setTimeout(reject, ms, new BrowserError(errorMessage));
      return timer;
    }),
    promise.then(value => {
      clearTimeout(timer);
      return value;
    })
  ]);
}
async function timeout ( promise , ms , errorMessage ) { let timer = null ; return Promise . race ( [ new Promise ( ( resolve , reject ) => { timer = setTimeout ( reject , ms , new BrowserError ( errorMessage ) ) ; return timer ; } ) , promise . then ( value => { clearTimeout ( timer ) ; return value ; } ) ] ) ; }
Timeout a promise after ms. Use promise.race to compete
about the timeout and the promise.
@param {promise} promise - The promise to wait for
@param {int} ms - how long in ms to wait for the promise to fininsh
@param {string} errorMessage - the error message in the Error if we timeouts
Timeout a promise after ms . Use promise . race to compete about the timeout and the promise .