Skip to content

Commit 2084404

Browse files
andrewbranchorta
andauthored
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 <[email protected]>
1 parent f645418 commit 2084404

File tree

4 files changed

+24
-173
lines changed

4 files changed

+24
-173
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
- name: Linter
4343
run: npm run lint:ci
4444

45+
- name: Adding playwright
46+
run: npm install --no-save --no-package-lock playwright
47+
4548
- name: Validate the browser can import TypeScript
4649
run: gulp test-browser-integration
4750

package-lock.json

Lines changed: 0 additions & 169 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"mocha-fivemat-progress-reporter": "latest",
8989
"ms": "latest",
9090
"node-fetch": "^2.6.0",
91-
"playwright": "0.12.1",
9291
"plugin-error": "latest",
9392
"pretty-hrtime": "^1.0.3",
9493
"prex": "^0.4.3",

scripts/browserIntegrationTest.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
const playwright = require("playwright");
1+
// @ts-check
22
const chalk = require("chalk");
33
const { join } = require("path");
44
const { readFileSync } = require("fs");
5+
try {
6+
// eslint-disable-next-line import/no-extraneous-dependencies
7+
require("playwright");
8+
}
9+
catch (error) {
10+
throw new Error("Playwright is expected to be installed manually before running this script");
11+
}
12+
13+
// eslint-disable-next-line import/no-extraneous-dependencies
14+
const playwright = require("playwright");
515

616
// Turning this on will leave the Chromium browser open, giving you the
717
// chance to open up the web inspector.
818
const debugging = false;
919

1020
(async () => {
11-
for (const browserType of ["chromium", "firefox", "webkit"]) {
21+
for (const browserType of ["chromium", "firefox"]) {
1222
const browser = await playwright[browserType].launch({ headless: !debugging });
1323
const context = await browser.newContext();
1424
const page = await context.newPage();
@@ -21,7 +31,6 @@ const debugging = false;
2131

2232
page.on("error", errorCaught);
2333
page.on("pageerror", errorCaught);
24-
page.on("console", log => console[log._type](log._text));
2534

2635
await page.setContent(`
2736
<html>
@@ -35,5 +44,14 @@ const debugging = false;
3544
else {
3645
console.log("Not closing the browser, you'll need to exit the process in your terminal manually");
3746
}
47+
console.log(`${browserType} :+1:`);
3848
}
3949
})();
50+
51+
process.on("unhandledRejection", (/** @type {any}*/ err) => {
52+
if (err) {
53+
console.error(err.stack || err.message);
54+
}
55+
process.exit(1);
56+
});
57+

0 commit comments

Comments
 (0)