From 1c0ecc3d9cac9b4701b0d562fd1f3e0afcdaf4c5 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 31 May 2018 16:39:49 -0700 Subject: [PATCH] test: fix flaky test (#2650) When launching browser with a default URL, the page is not necessarily loaded when we're reaching into it. --- test/puppeteer.spec.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/puppeteer.spec.js b/test/puppeteer.spec.js index acad4ea51b4..783d6af68c9 100644 --- a/test/puppeteer.spec.js +++ b/test/puppeteer.spec.js @@ -282,8 +282,11 @@ module.exports.addTests = function({testRunner, expect, PROJECT_ROOT, defaultBro const options = Object.assign({}, defaultBrowserOptions); options.args = [customUrl].concat(options.args); const browser = await puppeteer.launch(options); - const pages = (await browser.pages()).map(page => page.url()); - expect(pages).toEqual([customUrl]); + const pages = await browser.pages(); + expect(pages.length).toBe(1); + if (pages[0].url() !== customUrl) + await pages[0].waitForNavigation(); + expect(pages[0].url()).toBe(customUrl); await browser.close(); }); });