Reputation: 15
What should I do when I get a timeout error for async tests and hooks?
My code is :
const puppeteer = require('puppeteer');
describe('My First Puppeteer Test', () =>{
it('should launch the browser', async function(){
const browser = await puppeteer.launch({headless: false, slowMo: 500});
const page = await browser.newPage();
await page.goto('https://www.google.com');
await browser.close();
})
})
Upvotes: 1
Views: 1483
Reputation: 400
You can set a default timeout for all navigation operations using:
const page = await browser.newPage();
page.setDefaultNavigationTimeout(10000);
Or you can also set the timeout for a specific page.goto
operation using:
await page.goto('https://www.google.com', {waitUntil: 'load', timeout: 10000});
Upvotes: 1