Install playwright on demand (#40722)

* Remove playwright from package.json

* Install playwright on demand

* Adds debugging info to the playwright script

* Move installation first

* Get it working on node 10 again

* Update browserIntegrationTest.js

* Update browserIntegrationTest.js

Co-authored-by: Orta <git@orta.io>
This commit is contained in:
Andrew Branch
2020-09-29 12:22:04 -07:00
committed by GitHub
parent f645418833
commit 2084404b8f
4 changed files with 24 additions and 173 deletions

View File

@@ -1,14 +1,24 @@
const playwright = require("playwright");
// @ts-check
const chalk = require("chalk");
const { join } = require("path");
const { readFileSync } = require("fs");
try {
// eslint-disable-next-line import/no-extraneous-dependencies
require("playwright");
}
catch (error) {
throw new Error("Playwright is expected to be installed manually before running this script");
}
// eslint-disable-next-line import/no-extraneous-dependencies
const playwright = require("playwright");
// Turning this on will leave the Chromium browser open, giving you the
// chance to open up the web inspector.
const debugging = false;
(async () => {
for (const browserType of ["chromium", "firefox", "webkit"]) {
for (const browserType of ["chromium", "firefox"]) {
const browser = await playwright[browserType].launch({ headless: !debugging });
const context = await browser.newContext();
const page = await context.newPage();
@@ -21,7 +31,6 @@ const debugging = false;
page.on("error", errorCaught);
page.on("pageerror", errorCaught);
page.on("console", log => console[log._type](log._text));
await page.setContent(`
<html>
@@ -35,5 +44,14 @@ const debugging = false;
else {
console.log("Not closing the browser, you'll need to exit the process in your terminal manually");
}
console.log(`${browserType} :+1:`);
}
})();
process.on("unhandledRejection", (/** @type {any}*/ err) => {
if (err) {
console.error(err.stack || err.message);
}
process.exit(1);
});