salix/e2e/helpers/puppeteer.js

23 lines
634 B
JavaScript

import Puppeteer from 'puppeteer';
import {extendPage} from './extensions';
import {url as defaultURL} from './config';
export async function getBrowser() {
const browser = await Puppeteer.launch({
args: [
`--window-size=${ 1920 },${ 1080 }`
],
defaultViewport: null,
headless: false,
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;