salix/e2e/helpers/puppeteer.js

25 lines
707 B
JavaScript
Raw Normal View History

2019-11-25 08:13:20 +00:00
2019-12-12 07:37:35 +00:00
import Puppeteer from 'puppeteer';
import {extendPage} from './extensions';
import {url as defaultURL} from './config';
2019-11-25 08:13:20 +00:00
export async function getBrowser() {
2020-02-05 08:08:55 +00:00
let headless = !process.env.E2E_SHOW;
const browser = await Puppeteer.launch({
args: [
2020-01-28 10:56:26 +00:00
'--no-sandbox',
`--window-size=${ 1920 },${ 1080 }`
],
defaultViewport: null,
2020-02-04 15:21:10 +00:00
headless: headless,
slowMo: 0, // slow down by ms
2019-12-12 07:37:35 +00:00
});
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)};
2019-12-12 07:37:35 +00:00
}
2019-11-25 08:13:20 +00:00
export default getBrowser;