fix(launcher): launcher.launch() should pass 'timeout' option #5180 (#7596)

Co-authored-by: Bob Jamison <bob.jamison@pearson.com>
This commit is contained in:
Jan Scheffler 2021-09-27 10:01:35 +02:00 committed by GitHub
parent f2e19276ac
commit 113489d3b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -164,7 +164,7 @@ class ChromeLauncher implements ProductLauncher {
runner.close.bind(runner)
);
if (waitForInitialPage)
await browser.waitForTarget((t) => t.type() === 'page');
await browser.waitForTarget((t) => t.type() === 'page', { timeout });
return browser;
} catch (error) {
runner.kill();
@ -336,7 +336,7 @@ class FirefoxLauncher implements ProductLauncher {
runner.close.bind(runner)
);
if (waitForInitialPage)
await browser.waitForTarget((t) => t.type() === 'page');
await browser.waitForTarget((t) => t.type() === 'page', { timeout });
return browser;
} catch (error) {
runner.kill();

View File

@ -392,6 +392,15 @@ describe('Launcher specs', function () {
await browser.close();
}
);
it('should pass the timeout parameter to browser.waitForTarget', async () => {
const { puppeteer, defaultBrowserOptions } = getTestState();
const options = Object.assign({}, defaultBrowserOptions, {
timeout: 1,
});
let error = null;
await puppeteer.launch(options).catch((error_) => (error = error_));
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
});
it('should set the default viewport', async () => {
const { puppeteer, defaultBrowserOptions } = getTestState();
const options = Object.assign({}, defaultBrowserOptions, {