Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(watch): hide show-report prompt (#32666)

Simon Knott443f72dcbe35
diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.ts
index fd1fb0cbdf..5aada7e495 100644
--- a/packages/playwright/src/reporters/html.ts
+++ b/packages/playwright/src/reporters/html.ts
@@ -143,7 +143,7 @@ class HtmlReporter implements ReporterV2 {
const shouldOpen = !this._options._isTestServer && (this._open === 'always' || (!ok && this._open === 'on-failure'));
if (shouldOpen) {
await showHTMLReport(this._outputFolder, this._host, this._port, singleTestId);
- } else if (this._options._mode === 'test') {
+ } else if (this._options._mode === 'test' && !this._options._isTestServer) {
const packageManagerCommand = getPackageManagerExecCommand();
const relativeReportPath = this._outputFolder === standaloneDefaultFolder() ? '' : ' ' + path.relative(process.cwd(), this._outputFolder);
const hostArg = this._host ? ` --host ${this._host}` : '';
diff --git a/tests/playwright-test/watch.spec.ts b/tests/playwright-test/watch.spec.ts
index b56fb470ea..4f687f72fc 100644
--- a/tests/playwright-test/watch.spec.ts
+++ b/tests/playwright-test/watch.spec.ts
@@ -215,6 +215,24 @@ test('should run tests on Enter', async ({ runWatchTest }) => {
await testProcess.waitForOutput('Waiting for file changes.');
});
+test('should not print show-report command of HTML reporter', async ({ runWatchTest }) => {
+ const testProcess = await runWatchTest({
+ 'a.test.ts': `
+ import { test, expect } from '@playwright/test';
+ test('passes', () => {});
+ `,
+ 'playwright.config.ts': `
+ import { defineConfig } from '@playwright/test';
+ export default defineConfig({ reporter: 'html' });
+ `,
+ });
+ await testProcess.waitForOutput('Waiting for file changes.');
+ testProcess.clearOutput();
+ testProcess.write('\r\n');
+ await testProcess.waitForOutput('Waiting for file changes.');
+ expect(testProcess.output).not.toContain('To open last HTML report run:');
+});
+
test('should run tests on R', async ({ runWatchTest }) => {
const testProcess = await runWatchTest({
'a.test.ts': `