salix/e2e/helpers/puppeteer.js

25 lines
707 B
JavaScript

import Puppeteer from 'puppeteer';
import {extendPage} from './extensions';
import {url as defaultURL} from './config';
export async function getBrowser() {
let headless = !process.env.E2E_SHOW;
const browser = await Puppeteer.launch({
args: [
'--no-sandbox',
`--window-size=${ 1920 },${ 1080 }`
],
defaultViewport: null,
headless: headless,
slowMo: 0, // slow down by ms
});
let page = (await browser.pages())[0];
page = extendPage(page);
page.setDefaultTimeout(5000);
await page.goto(defaultURL, {waitUntil: 'networkidle0'});
return {page, close: browser.close.bind(browser)};
}
export default getBrowser;