Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: make sure browser crashes in CLI tests are marked as such (#15821)
Dmitry Gozmanba3c8ffa5cfb
diff --git a/packages/playwright-core/src/cli/cli.ts b/packages/playwright-core/src/cli/cli.tsindex aaf8bb27e7..b5a4cc7320 100755--- a/packages/playwright-core/src/cli/cli.ts+++ b/packages/playwright-core/src/cli/cli.ts@@ -410,6 +410,23 @@ async function launchContext(options: Options, headless: boolean, executablePathconst browser = await browserType.launch(launchOptions);+ if (process.env.PWTEST_CLI_EXIT) {+ const logs: string[] = [];+ require('playwright-core/lib/utilsBundle').debug.log = (...args: any[]) => {+ const line = require('util').format(...args) + '\n';+ logs.push(line);+ process.stderr.write(line);+ };+ browser.on('disconnected', () => {+ const hasCrashLine = logs.some(line => line.includes('process did exit:') && !line.includes('process did exit: exitCode=0, signal=null'));+ if (hasCrashLine) {+ process.stderr.write('Detected browser crash.\n');+ // Make sure we exit abnormally when browser crashes.+ process.exit(1);+ }+ });+ }+// Viewport sizeif (options.viewportSize) {try {diff --git a/tests/library/inspector/inspectorTest.ts b/tests/library/inspector/inspectorTest.tsindex 2771c6d492..a422e866f9 100644--- a/tests/library/inspector/inspectorTest.ts+++ b/tests/library/inspector/inspectorTest.ts@@ -60,7 +60,7 @@ export const test = contextTest.extend<CLITestArgs>({return cli;});if (cli)- await cli.exited;+ await cli.exited.catch(() => {});},openRecorder: async ({ page, recorderPageGetter }, run) => {@@ -199,6 +199,7 @@ class CLIMock {PWTEST_CLI_EXIT: '1',PWTEST_CLI_HEADLESS: headless ? '1' : undefined,PWTEST_CLI_EXECUTABLE_PATH: executablePath,+ DEBUG: (process.env.DEBUG ?? '') + ',pw:browser*',},});this.process.onOutput = () => {