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