salix/e2e/helpers/puppeteer.js

23 lines
634 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() {
const browser = await Puppeteer.launch({
args: [
`--window-size=${ 1920 },${ 1080 }`
],
defaultViewport: null,
headless: false,
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;