feat: better timeout stack trace (#2843)

fixes #2653
This commit is contained in:
Yaniv Efraim 2018-07-05 02:39:09 +03:00 committed by Andrey Lushnikov
parent 22fa00a7b3
commit cfc0571c1a
2 changed files with 9 additions and 2 deletions

View File

@ -836,8 +836,10 @@ class WaitTask {
});
// Since page navigation requires us to re-install the pageScript, we should track
// timeout on our end.
if (timeout)
this._timeoutTimer = setTimeout(() => this.terminate(new Error(`waiting for ${title} failed: timeout ${timeout}ms exceeded`)), timeout);
if (timeout) {
const timeoutError = new Error(`waiting for ${title} failed: timeout ${timeout}ms exceeded`);
this._timeoutTimer = setTimeout(() => this.terminate(timeoutError), timeout);
}
this.rerun();
}

View File

@ -332,6 +332,11 @@ module.exports.addTests = function({testRunner, expect}) {
await page.setContent(`<div class='zombo'>anything</div>`);
expect(await page.evaluate(x => x.textContent, await waitForSelector)).toBe('anything');
});
it('should have correct stack trace for timeout', async({page, server}) => {
let error;
await page.waitForSelector('.zombo', {timeout: 10}).catch(e => error = e);
expect(error.stack).toContain('frame.spec.js');
});
});
describe('Frame.waitForXPath', function() {