2020-12-22 13:10:20 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
const os = require('os');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
const { green } = require('kleur');
|
|
|
|
const puppeteer = require('puppeteer');
|
|
|
|
|
|
|
|
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
|
|
|
|
|
|
|
|
module.exports = async function () {
|
|
|
|
console.log(green('Setup Puppeteer'));
|
|
|
|
const browser = await puppeteer.launch({
|
2021-03-06 18:56:45 +01:00
|
|
|
isMobile: false,
|
|
|
|
ignoreHTTPSErrors: true,
|
|
|
|
// invert values for local testing
|
|
|
|
devtools: false,
|
2020-12-22 13:10:20 +01:00
|
|
|
headless: true,
|
2021-03-06 18:56:45 +01:00
|
|
|
// slowMo: 6000,
|
|
|
|
// invert values for local testing
|
2020-12-22 13:10:20 +01:00
|
|
|
args: ['--no-sandbox'],
|
|
|
|
});
|
|
|
|
global.__BROWSER__ = browser;
|
2021-05-02 09:52:12 +02:00
|
|
|
fs.mkdirSync(DIR, { recursive: true });
|
2020-12-22 13:10:20 +01:00
|
|
|
fs.writeFileSync(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint());
|
|
|
|
};
|