diff --git a/README.md b/README.md index 9bb777d..85e260f 100644 --- a/README.md +++ b/README.md @@ -61,11 +61,24 @@ When using your test driver package, you will need to install the necessary NPM ### Puppeteer +`puppeteer@^19.11.1` is the latest version with Node 14 compatibility (Meteor 2.x is set to use Node.js version 14.x by default). + ```bash -$ npm i --save-dev puppeteer@^1.5.0 +$ npm i --save-dev puppeteer@^19.11.1 $ TEST_BROWSER_DRIVER=puppeteer meteor test --once --driver-package ``` +### Playwright + +`playwright@^1.33.0` is the latest version with Node 14 compatibility (Meteor 2.x is set to use Node.js version 14.x by default). + +```bash +$ npm i --save-dev playwright@^1.33.0 +$ TEST_BROWSER_DRIVER=playwright meteor test --once --driver-package +``` + +Use `PLAYWRIGHT_BROWSER` env to select the browser to use for testing. By default, it uses `chromium`. + ### Selenium ChromeDriver Meteor 1.6+: diff --git a/browser/chromedriver.js b/browser/chromedriver.js index 0ef9f4d..0a0672d 100644 --- a/browser/chromedriver.js +++ b/browser/chromedriver.js @@ -58,6 +58,8 @@ export default function startChrome({ // Can't hide the window but can move it off screen driver.manage().window().setRect(20000, 20000); + const LogsArgsRegex = /"([^"]*)"|(\b\d+\b)/g; + // We periodically grab logs from Chrome and pass them back. // Every time we call this, we get only the log entries since // the previous time we called it. @@ -70,7 +72,7 @@ export default function startChrome({ stderr(`[ERROR] ${message}`); } else { function extractArgs(str) { - let rex = /"([^"]*)"|(\b\d+\b)/g; + let rex = LogsArgsRegex; let match; let args = []; while ((match = rex.exec(str)) !== null) { diff --git a/browser/nightmare.js b/browser/nightmare.js index ceb41c0..e87ba23 100644 --- a/browser/nightmare.js +++ b/browser/nightmare.js @@ -15,6 +15,8 @@ const TWENTY_DAYS = 1000 * 60 * 60 * 24 * 20; let nightmare; +process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true; + // Make sure the nightmare process does not stick around process.on('exit', () => { if (nightmare) { @@ -65,7 +67,10 @@ export default function startNightmare({ // Meteor will call the `runTests` function exported by the driver package // on the client as soon as this page loads. - .goto(process.env.ROOT_URL) + .goto(process.env.ROOT_URL, { + 'http-equiv': 'Content-Security-Policy', + content: 'script-src \'unsafe-eval\'', + }) // After the page loads, the tests are running. Eventually they // finish and the driver package is supposed to set window.testsDone diff --git a/browser/puppeteer.js b/browser/puppeteer.js index 6605bff..3ad36e0 100644 --- a/browser/puppeteer.js +++ b/browser/puppeteer.js @@ -30,6 +30,7 @@ export default function startPuppeteer({ // --no-sandbox and --disable-setuid-sandbox allow this to easily run in docker const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'], + headless: 'new', }); console.log(await browser.version()); const page = await browser.newPage();