From 2bcc6f6ad034a990be222d8c86e016f587d142de Mon Sep 17 00:00:00 2001 From: TonyRL Date: Wed, 4 May 2022 20:35:20 +0000 Subject: [PATCH] test: puppeteer wait until test finish --- test/utils/puppeteer.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/utils/puppeteer.js b/test/utils/puppeteer.js index 5c63f42a4..8b453af49 100644 --- a/test/utils/puppeteer.js +++ b/test/utils/puppeteer.js @@ -27,7 +27,9 @@ describe('puppeteer', () => { puppeteer = require('../../lib/utils/puppeteer'); const browser = await puppeteer({ stealth: false }); const page = await browser.newPage(); - await page.goto('https://bot.sannysoft.com'); + await page.goto('https://bot.sannysoft.com', { + waitUntil: 'networkidle0', + }); const html = await page.evaluate(() => document.body.innerHTML); const $ = cheerio.load(html); @@ -37,12 +39,14 @@ describe('puppeteer', () => { const chromeTest = $('tbody tr').eq(4).find('td').eq(1).text().trim(); expect(webDriverTest).toBe('present (failed)'); expect(chromeTest).toBe('missing (failed)'); - }); + }, 10000); it('puppeteer with stealth', async () => { puppeteer = require('../../lib/utils/puppeteer'); const browser = await puppeteer({ stealth: true }); const page = await browser.newPage(); - await page.goto('https://bot.sannysoft.com'); + await page.goto('https://bot.sannysoft.com', { + waitUntil: 'networkidle0', + }); const html = await page.evaluate(() => document.body.innerHTML); const $ = cheerio.load(html); @@ -51,5 +55,5 @@ describe('puppeteer', () => { const chromeTest = $('tbody tr').eq(4).find('td').eq(1).text().trim(); expect(webDriverTest).toBe('missing (passed)'); expect(chromeTest).toBe('present (passed)'); - }); + }, 10000); });