Skip to content

Install playwright on demand #40722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- name: Linter
run: npm run lint:ci

- name: Adding playwright
run: npm install --no-save --no-package-lock playwright
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I put this in browserIntegrationTest.js is so it would work locally without extra magic steps, but if you don’t care about running locally (I guess nobody would really want to do that), this is fine


- name: Validate the browser can import TypeScript
run: gulp test-browser-integration

169 changes: 0 additions & 169 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"mocha-fivemat-progress-reporter": "latest",
"ms": "latest",
"node-fetch": "^2.6.0",
"playwright": "0.12.1",
"plugin-error": "latest",
"pretty-hrtime": "^1.0.3",
"prex": "^0.4.3",
Expand Down
24 changes: 21 additions & 3 deletions scripts/browserIntegrationTest.js
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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>
Expand All @@ -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);
});