Skip to content

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

chore: remove onTestPaused from reporters (#43570)

Dmitry Gozmaneecb129caa67
diff --git a/packages/playwright/src/cli/testActions.ts b/packages/playwright/src/cli/testActions.ts
index c9f529e450..59c13196c9 100644
--- a/packages/playwright/src/cli/testActions.ts
+++ b/packages/playwright/src/cli/testActions.ts
@@ -116,7 +116,6 @@ function overridesFromOptions(options: { [key: string]: any }): ipc.ConfigCLIOve
globalTimeout: options.globalTimeout ? parseInt(options.globalTimeout, 10) : undefined,
maxFailures: options.x ? 1 : (options.maxFailures ? parseInt(options.maxFailures, 10) : undefined),
outputDir: options.output ? path.resolve(process.cwd(), options.output) : undefined,
- pause: !!process.env.PWPAUSE,
quiet: options.quiet ? options.quiet : undefined,
repeatEach: options.repeatEach ? parseInt(options.repeatEach, 10) : undefined,
retries: options.retries ? parseInt(options.retries, 10) : undefined,
diff --git a/packages/playwright/src/common/config.ts b/packages/playwright/src/common/config.ts
index 75b07ee2c3..3bb4335281 100644
--- a/packages/playwright/src/common/config.ts
+++ b/packages/playwright/src/common/config.ts
@@ -111,7 +111,7 @@ export class FullConfigInternal {
updateSnapshots: takeFirst(configCLIOverrides.updateSnapshots, userConfig.updateSnapshots, 'default'),
updateSourceMethod: takeFirst(configCLIOverrides.updateSourceMethod, userConfig.updateSourceMethod, 'patch'),
version: packageJSON.version,
- workers: resolveWorkers(takeFirst((configCLIOverrides.debug || configCLIOverrides.pause) ? 1 : undefined, configCLIOverrides.workers, userConfig.workers, '50%')),
+ workers: resolveWorkers(takeFirst(configCLIOverrides.debug ? 1 : undefined, configCLIOverrides.workers, userConfig.workers, '50%')),
webServer: null,
};
for (const key in userConfig) {
diff --git a/packages/playwright/src/common/ipc.ts b/packages/playwright/src/common/ipc.ts
index f282d85bc3..371361b3e7 100644
--- a/packages/playwright/src/common/ipc.ts
+++ b/packages/playwright/src/common/ipc.ts
@@ -31,7 +31,6 @@ export type ConfigCLIOverrides = {
globalTimeout?: number;
maxFailures?: number;
outputDir?: string;
- pause?: boolean;
quiet?: boolean;
repeatEach?: number;
retries?: number;
@@ -96,11 +95,8 @@ export type TestInfoErrorPayload = {
export type TestPausedPayload = {
testId: string;
errors: TestInfoErrorPayload[];
- status: TestStatus;
};
-export type ResumePayload = {};
-
export type CustomMessageRequestPayload = {
testId: string;
request: any;
diff --git a/packages/playwright/src/isomorphic/teleReceiver.ts b/packages/playwright/src/isomorphic/teleReceiver.ts
index f4c76d5b2d..10f7f59ddb 100644
--- a/packages/playwright/src/isomorphic/teleReceiver.ts
+++ b/packages/playwright/src/isomorphic/teleReceiver.ts
@@ -136,7 +136,7 @@ export type JsonFullResult = {
};
export type JsonEvent = JsonOnConfigureEvent | JsonOnBlobReportMetadataEvent | JsonOnEndEvent | JsonOnExitEvent | JsonOnProjectEvent | JsonOnBeginEvent | JsonOnTestBeginEvent
- | JsonOnTestEndEvent | JsonOnStepBeginEvent | JsonOnStepEndEvent | JsonOnAttachEvent | JsonOnErrorEvent | JsonOnTestPausedEvent | JsonOnStdIOEvent;
+ | JsonOnTestEndEvent | JsonOnStepBeginEvent | JsonOnStepEndEvent | JsonOnAttachEvent | JsonOnErrorEvent | JsonOnStdIOEvent;
export type JsonOnConfigureEvent = {
method: 'onConfigure';
@@ -170,15 +170,6 @@ export type JsonOnTestBeginEvent = {
};
};
-export type JsonOnTestPausedEvent = {
- method: 'onTestPaused';
- params: {
- testId: string;
- resultId: string;
- errors: reporterTypes.TestError[];
- };
-};
-
export type JsonOnTestEndEvent = {
method: 'onTestEnd';
params: {
@@ -296,10 +287,6 @@ export class TeleReporterReceiver {
this._onTestBegin(params.testId, params.result);
return;
}
- if (method === 'onTestPaused') {
- this._onTestPaused(params.testId, params.resultId, params.errors);
- return;
- }
if (method === 'onTestEnd') {
this._onTestEnd(params.test, params.result);
return;
@@ -375,15 +362,6 @@ export class TeleReporterReceiver {
this._reporter.onTestBegin?.(test, testResult);
}
- private _onTestPaused(testId: string, resultId: string, errors: reporterTypes.TestError[]) {
- const test = this._tests.get(testId)!;
- const result = test.results.find(r => r._id === resultId)!;
-
- result.errors.push(...errors);
- result.error = result.errors[0];
- void this._reporter.onTestPaused?.(test, result);
- }
-
private _onTestEnd(testEndPayload: JsonTestEnd, payload: JsonTestResultEnd) {
const test = this._tests.get(testEndPayload.testId)!;
test.timeout = testEndPayload.timeout;
diff --git a/packages/playwright/src/mcp/test/testContext.ts b/packages/playwright/src/mcp/test/testContext.ts
index f073bb752e..528a7e9eef 100644
--- a/packages/playwright/src/mcp/test/testContext.ts
+++ b/packages/playwright/src/mcp/test/testContext.ts
@@ -212,7 +212,7 @@ export class TestContext {
claimStdio();
try {
- const setupReporter = new MCPListReporter({ configDir, screen, includeTestId: true });
+ const setupReporter = new ListReporter({ configDir, screen, includeTestId: true });
const { status } = await runner.runGlobalSetup([setupReporter]);
if (status !== 'passed')
return { output: testRunnerAndScreen.output.join('\n'), status };
@@ -239,7 +239,7 @@ export class TestContext {
: new Promise<never>(() => {});
try {
- const reporter = new MCPListReporter({ configDir, screen, includeTestId: true });
+ const reporter = new ListReporter({ configDir, screen, includeTestId: true });
status = await Promise.race([
runner.runTests(reporter, params).then(result => result.status),
testRunnerAndScreen.waitForTestPaused().then(() => 'paused' as const),
@@ -341,10 +341,3 @@ const bestPracticesMarkdown = `
- NEVER! use page.waitForTimeout()
- NEVER! use page.evaluate()
`;
-
-class MCPListReporter extends ListReporter {
- override async onTestPaused() {
- // ListReporter waits for user input to resume, we don't want that in MCP.
- await new Promise<void>(() => {});
- }
-}
diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts
index 87ce46efb7..553e58038e 100644
--- a/packages/playwright/src/reporters/base.ts
+++ b/packages/playwright/src/reporters/base.ts
@@ -522,12 +522,6 @@ function quotePathIfNeeded(path: string): string {
return path;
}
-const kReportedSymbol = Symbol('reported');
-
-export function markErrorsAsReported(result: TestResult) {
- (result as any)[kReportedSymbol] = result.errors.length;
-}
-
export function formatResultFailure(screen: Screen, test: TestCase, result: TestResult, initialIndent: string): ErrorDetails[] {
const errorDetails: ErrorDetails[] = [];
@@ -542,8 +536,7 @@ export function formatResultFailure(screen: Screen, test: TestCase, result: Test
});
}
- const reportedIndex = (result as any)[kReportedSymbol] || 0;
- for (const error of result.errors.slice(reportedIndex)) {
+ for (const error of result.errors) {
const formattedError = formatError(screen, error);
errorDetails.push({
message: indent(formattedError.message, initialIndent),
diff --git a/packages/playwright/src/reporters/blob.ts b/packages/playwright/src/reporters/blob.ts
index 9590a9e1b2..a1411271a6 100644
--- a/packages/playwright/src/reporters/blob.ts
+++ b/packages/playwright/src/reporters/blob.ts
@@ -29,7 +29,7 @@ import { resolveOutputFile, CommonReporterOptions } from './base';
import { TeleReporterEmitter } from './teleEmitter';
import type { BlobReporterOptions } from '../../types/test';
-import type { FullConfig, FullResult, TestCase, TestResult } from '../../types/testReporter';
+import type { FullConfig, FullResult, TestResult } from '../../types/testReporter';
import type { BlobReportMetadata, JsonAttachment, JsonEvent } from '../isomorphic/teleReceiver';
import type { EventEmitter } from 'events';
@@ -68,11 +68,6 @@ export class BlobReporter extends TeleReporterEmitter {
super.onConfigure(config);
}
- override async onTestPaused(test: TestCase, result: TestResult) {
- // onTestPaused is only relevant for interactive use, not for blob replays.
- // merge-reports still gets onStepBegin/onStepEnd for pausing, but not the interactive part, so this is a no-op.
- }
-
override async onEnd(result: FullResult): Promise<void> {
await super.onEnd(result);
diff --git a/packages/playwright/src/reporters/dot.ts b/packages/playwright/src/reporters/dot.ts
index dd3812b44a..cc90479405 100644
--- a/packages/playwright/src/reporters/dot.ts
+++ b/packages/playwright/src/reporters/dot.ts
@@ -16,7 +16,7 @@
import { getAsBooleanFromENV } from '@utils/env';
-import { markErrorsAsReported, TerminalReporter } from './base';
+import { TerminalReporter } from './base';
import type { DotReporterOptions } from '../../types/test';
import type { FullResult, Suite, TestCase, TestError, TestResult } from '../../types/testReporter';
@@ -74,26 +74,6 @@ class DotReporter extends TerminalReporter {
this._counter = 0;
}
- async onTestPaused(test: TestCase, result: TestResult) {
- // Without TTY, user cannot interrupt the pause. Let's skip it.
- if (!process.stdin.isTTY && !process.env.PW_TEST_DEBUG_REPORTERS)
- return;
-
- this.screen.stdout.write('\n');
- if (test.outcome() === 'unexpected') {
- this.writeLine(this.screen.colors.red(this.formatTestHeader(test, { indent: ' ' })));
- this.writeLine(this.formatResultErrors(test, result));
- markErrorsAsReported(result);
- this.writeLine(this.screen.colors.yellow(' Paused on error. Press Ctrl+C to end.') + '\n');
- } else {
- this.writeLine(this.screen.colors.yellow(this.formatTestHeader(test, { indent: ' ' })));
- this.writeLine(this.screen.colors.yellow(' Paused at test end. Press Ctrl+C to end.') + '\n');
- }
- this._counter = 0;
-
- await new Promise<void>(() => {});
- }
-
override async onEnd(result: FullResult) {
await super.onEnd(result);
this.screen.stdout.write('\n');
diff --git a/packages/playwright/src/reporters/failures.ts b/packages/playwright/src/reporters/failures.ts
index cf063e5d09..d79cdfb85f 100644
--- a/packages/playwright/src/reporters/failures.ts
+++ b/packages/playwright/src/reporters/failures.ts
@@ -17,7 +17,7 @@
import { msToString } from '@isomorphic/formatUtils';
import { getAsBooleanFromENV } from '@utils/env';
-import { markErrorsAsReported, TerminalReporter } from './base';
+import { TerminalReporter } from './base';
import type { FailuresReporterOptions } from '../../types/test';
import type { FullResult, TestCase, TestError, TestResult } from '../../types/testReporter';
@@ -80,23 +80,6 @@ class FailuresReporter extends TerminalReporter {
this.writeLine(this.formatError(error).message);
}
- async onTestPaused(test: TestCase, result: TestResult) {
- // Without TTY, the user cannot interrupt the pause.
- if (!process.stdin.isTTY && !process.env.PW_TEST_DEBUG_REPORTERS)
- return;
-
- this._maybeWriteNewLine();
- if (test.outcome() === 'unexpected') {
- this._printFailure(test);
- markErrorsAsReported(result);
- this.writeLine(this.screen.colors.yellow(' Paused on error. Press Ctrl+C to end.'));
- } else {
- this.writeLine(this.screen.colors.yellow(this.formatTestHeader(test, { indent: ' ' })));
- this.writeLine(this.screen.colors.yellow(' Paused at test end. Press Ctrl+C to end.'));
- }
- await new Promise<void>(() => {});
- }
-
override async onEnd(result: FullResult) {
await super.onEnd(result);
this._maybeWriteNewLine();
diff --git a/packages/playwright/src/reporters/internalReporter.ts b/packages/playwright/src/reporters/internalReporter.ts
index 68384d8f49..92aeb43843 100644
--- a/packages/playwright/src/reporters/internalReporter.ts
+++ b/packages/playwright/src/reporters/internalReporter.ts
@@ -74,11 +74,6 @@ export class InternalReporter implements ReporterV2 {
this._reporter.onStdErr?.(chunk, test, result);
}
- async onTestPaused(test: TestCase, result: TestResult) {
- this._addSnippetToTestErrors(test, result);
- return await this._reporter.onTestPaused?.(test, result);
- }
-
onTestEnd(test: TestCase, result: TestResult) {
this._addSnippetToTestErrors(test, result);
this._reporter.onTestEnd?.(test, result);
diff --git a/packages/playwright/src/reporters/line.ts b/packages/playwright/src/reporters/line.ts
index c703d3cc01..3932aa2e32 100644
--- a/packages/playwright/src/reporters/line.ts
+++ b/packages/playwright/src/reporters/line.ts
@@ -16,7 +16,7 @@
import { getAsBooleanFromENV } from '@utils/env';
-import { markErrorsAsReported, TerminalReporter } from './base';
+import { TerminalReporter } from './base';
import type { LineReporterOptions } from '../../types/test';
import type { FullResult, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter';
@@ -86,29 +86,6 @@ class LineReporter extends TerminalReporter {
this._updateLine(test, result, step.parent);
}
- async onTestPaused(test: TestCase, result: TestResult) {
- // without TTY, user cannot interrupt the pause. let's skip it.
- if (!process.stdin.isTTY && !process.env.PW_TEST_DEBUG_REPORTERS)
- return;
-
- if (!process.env.PW_TEST_DEBUG_REPORTERS)
- this.screen.stdout.write(`\u001B[1A\u001B[2K`);
-
- if (test.outcome() === 'unexpected') {
- this.writeLine(this.screen.colors.red(this.formatTestHeader(test, { indent: ' ', index: ++this._failures })));
- this.writeLine(this.formatResultErrors(test, result));
- markErrorsAsReported(result);
- this.writeLine(this.screen.colors.yellow(` Paused on error. Press Ctrl+C to end.`) + '\n\n');
- } else {
- this.writeLine(this.screen.colors.yellow(this.formatTestHeader(test, { indent: ' ' })));
- this.writeLine(this.screen.colors.yellow(` Paused at test end. Press Ctrl+C to end.`) + '\n\n');
- }
-
- this._updateLine(test, result, undefined);
-
- await new Promise<void>(() => {});
- }
-
override onTestEnd(test: TestCase, result: TestResult) {
super.onTestEnd(test, result);
if (!this.willRetry(test) && (test.outcome() === 'flaky' || test.outcome() === 'unexpected' || result.status === 'interrupted')) {
diff --git a/packages/playwright/src/reporters/list.ts b/packages/playwright/src/reporters/list.ts
index 68db5a0eca..22591b39c8 100644
--- a/packages/playwright/src/reporters/list.ts
+++ b/packages/playwright/src/reporters/list.ts
@@ -17,7 +17,7 @@
import { msToString } from '@isomorphic/formatUtils';
import { getAsBooleanFromENV } from '@utils/env';
-import { markErrorsAsReported, TerminalReporter, stepSuffix } from './base';
+import { TerminalReporter, stepSuffix } from './base';
import { stripAnsiEscapes } from '../util';
import type { ListReporterOptions } from '../../types/test';
@@ -40,7 +40,6 @@ class ListReporter extends TerminalReporter {
private _printSteps: boolean;
private _printFailuresInline: boolean;
private _failureIndex = new Map<TestCase, number>();
- private _paused = new Set<TestResult>();
constructor(options?: ListReporterOptions & CommonReporterOptions & TerminalReporterOptions) {
const printFailuresInline = getAsBooleanFromENV('PLAYWRIGHT_LIST_PRINT_FAILURES_INLINE', options?.printFailuresInline);
@@ -170,33 +169,11 @@ class ListReporter extends TerminalReporter {
stream.write(chunk);
}
- async onTestPaused(test: TestCase, result: TestResult) {
- // Without TTY, user cannot interrupt the pause. Let's skip it.
- if (!process.stdin.isTTY && !process.env.PW_TEST_DEBUG_REPORTERS)
- return;
-
- this._paused.add(result);
-
- this._updateTestLine(test, result);
- this._maybeWriteNewLine();
- if (test.outcome() === 'unexpected') {
- const errors = this.formatResultErrors(test, result);
- this.writeLine(errors);
- this._updateLineCountAndNewLineFlagForOutput(errors);
- markErrorsAsReported(result);
- }
- this._appendLine(this.screen.colors.yellow(`Paused ${test.outcome() === 'unexpected' ? 'on error' : 'at test end'}. Press Ctrl+C to end.`), this._testPrefix('', ''));
-
- await new Promise<void>(() => {});
- }
-
override onTestEnd(test: TestCase, result: TestResult) {
super.onTestEnd(test, result);
- const wasPaused = this._paused.delete(result);
- if (!wasPaused)
- this._updateTestLine(test, result);
+ this._updateTestLine(test, result);
const isFailure = result.status !== 'skipped' && result.status !== test.expectedStatus;
- if (!wasPaused && this._printFailuresInline && isFailure)
+ if (this._printFailuresInline && isFailure)
this._printFailure(test);
}
diff --git a/packages/playwright/src/reporters/multiplexer.ts b/packages/playwright/src/reporters/multiplexer.ts
index 2a370e8fd8..8a8a151251 100644
--- a/packages/playwright/src/reporters/multiplexer.ts
+++ b/packages/playwright/src/reporters/multiplexer.ts
@@ -70,11 +70,6 @@ export class Multiplexer implements ReporterV2 {
this._wrap(() => reporter.onStdErr?.(chunk, test, result));
}
- async onTestPaused(test: TestCase, result: TestResult) {
- for (const reporter of this._reporters)
- await this._wrapAsync(() => reporter.onTestPaused?.(test, result));
- }
-
onTestEnd(test: TestCase, result: TestResult) {
for (const reporter of this._reporters)
this._wrap(() => reporter.onTestEnd?.(test, result));
diff --git a/packages/playwright/src/reporters/redactingReporter.ts b/packages/playwright/src/reporters/redactingReporter.ts
index 1c427186ec..297c240dc7 100644
--- a/packages/playwright/src/reporters/redactingReporter.ts
+++ b/packages/playwright/src/reporters/redactingReporter.ts
@@ -112,10 +112,6 @@ export class RedactingReporter implements ReporterV2 {
this._reporter.onStdErr?.(this._redactor.redact(chunk), this._redactor.redact(test), this._redactor.redact(result));
}
- async onTestPaused(test: TestCase, result: TestResult) {
- await this._reporter.onTestPaused?.(this._redactor.redact(test), this._redactor.redact(result));
- }
-
onTestEnd(test: TestCase, result: TestResult) {
this._reporter.onTestEnd?.(this._redactor.redact(test), this._redactor.redact(result));
}
diff --git a/packages/playwright/src/reporters/reporterV2.ts b/packages/playwright/src/reporters/reporterV2.ts
index 131e2475a5..10536dbffb 100644
--- a/packages/playwright/src/reporters/reporterV2.ts
+++ b/packages/playwright/src/reporters/reporterV2.ts
@@ -39,7 +39,6 @@ export interface ReporterV2 {
onTestBegin?(test: TestCase, result: TestResult): void;
onStdOut?(chunk: string | Buffer, test?: TestCase, result?: TestResult): void;
onStdErr?(chunk: string | Buffer, test?: TestCase, result?: TestResult): void;
- onTestPaused?(test: TestCase, result: TestResult): Promise<void>;
onTestEnd?(test: TestCase, result: TestResult): void;
onReportConfigure?(params: ReportConfigureParams): void;
onReportEnd?(params: ReportEndParams): void;
diff --git a/packages/playwright/src/reporters/teleEmitter.ts b/packages/playwright/src/reporters/teleEmitter.ts
index 71aa177bd6..8a42a11969 100644
--- a/packages/playwright/src/reporters/teleEmitter.ts
+++ b/packages/playwright/src/reporters/teleEmitter.ts
@@ -35,7 +35,6 @@ export class TeleReporterEmitter implements ReporterV2 {
private _rootDir!: string;
private _emitterOptions: TeleReporterEmitterOptions;
private _resultKnownAttachmentCounts = new Map<string, number>();
- private _resultKnownErrorCounts = new Map<string, number>();
// In case there is blob reporter and UI mode, make sure one doesn't override
// the id assigned by the other.
private readonly _idSymbol = Symbol('id');
@@ -72,21 +71,6 @@ export class TeleReporterEmitter implements ReporterV2 {
});
}
- async onTestPaused(test: reporterTypes.TestCase, result: reporterTypes.TestResult) {
- const resultId = (result as any)[this._idSymbol];
- this._resultKnownErrorCounts.set(resultId, result.errors.length);
- this._messageSink({
- method: 'onTestPaused',
- params: {
- testId: test.id,
- resultId,
- errors: result.errors,
- }
- });
- // keep the test paused until externally resumed
- await new Promise<void>(() => {});
- }
-
onTestEnd(test: reporterTypes.TestCase, result: reporterTypes.TestResult): void {
const testEnd: teleReceiver.JsonTestEnd = {
testId: test.id,
@@ -105,7 +89,6 @@ export class TeleReporterEmitter implements ReporterV2 {
const resultId = (result as any)[this._idSymbol];
this._resultKnownAttachmentCounts.delete(resultId);
- this._resultKnownErrorCounts.delete(resultId);
}
onStepBegin(test: reporterTypes.TestCase, result: reporterTypes.TestResult, step: reporterTypes.TestStep): void {
@@ -277,7 +260,7 @@ export class TeleReporterEmitter implements ReporterV2 {
id,
duration: result.duration,
status: result.status,
- errors: this._resultKnownErrorCounts.has(id) ? result.errors.slice(this._resultKnownAttachmentCounts.get(id)) : result.errors,
+ errors: result.errors,
annotations: result.annotations?.length ? this._relativeAnnotationLocations(result.annotations) : undefined,
};
}
diff --git a/packages/playwright/src/runner/dispatcher.ts b/packages/playwright/src/runner/dispatcher.ts
index 43ac3156e3..b574f4d2ef 100644
--- a/packages/playwright/src/runner/dispatcher.ts
+++ b/packages/playwright/src/runner/dispatcher.ts
@@ -637,7 +637,7 @@ class JobDispatcher {
if (!data)
return;
- const { result, test } = data;
+ const { test } = data;
const sendMessage = async (message: { request: any }) => {
try {
@@ -654,14 +654,9 @@ class JobDispatcher {
}
};
- result.status = params.status;
- result.errors = params.errors;
- result.error = result.errors[0];
-
- void this._testRun.reporter.onTestPaused?.(test, result).then(() => {
- worker.sendResume({});
- });
- this._testRun.onTestPaused({ ...params, sendMessage });
+ for (const error of params.errors)
+ addLocationAndSnippetToError(this._testRun.config.config, error, test.location.file);
+ this._testRun.onTestPaused({ errors: params.errors, sendMessage });
}
skipWholeJob(): boolean {
diff --git a/packages/playwright/src/runner/testRunner.ts b/packages/playwright/src/runner/testRunner.ts
index df44df98a1..26358d2cba 100644
--- a/packages/playwright/src/runner/testRunner.ts
+++ b/packages/playwright/src/runner/testRunner.ts
@@ -447,7 +447,7 @@ export async function runAllTestsWithConfig(config: FullConfigInternal, options:
...createRunTestsTasks(config),
];
- const testRun = new TestRun(config, reporter, { ...options, pauseAtEnd: config.configCLIOverrides.pause, pauseOnError: config.configCLIOverrides.pause });
+ const testRun = new TestRun(config, reporter, options);
const status = await runTasks(testRun, tasks, config.config.globalTimeout);
// Calling process.exit() might truncate large stdout/stderr output.
diff --git a/packages/playwright/src/runner/workerHost.ts b/packages/playwright/src/runner/workerHost.ts
index 2e1781c2d0..77409ebfcc 100644
--- a/packages/playwright/src/runner/workerHost.ts
+++ b/packages/playwright/src/runner/workerHost.ts
@@ -93,10 +93,6 @@ export class WorkerHost extends ProcessHost {
return await this.sendMessage({ method: 'customMessage', params: payload }) as ipc.CustomMessageResponsePayload;
}
- sendResume(payload: ipc.ResumePayload) {
- this.sendMessageNoReply({ method: 'resume', params: payload });
- }
-
hash() {
return this._hash;
}
diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.ts
index 810454c758..fcf902c297 100644
--- a/packages/playwright/src/worker/testInfo.ts
+++ b/packages/playwright/src/worker/testInfo.ts
@@ -73,14 +73,14 @@ type TestInfoCallbacks = {
onStepBegin: (payload: ipc.StepBeginPayload) => void;
onStepEnd: (payload: ipc.StepEndPayload) => void;
onAttach: (payload: ipc.AttachmentPayload) => void;
- onTestPaused: (payload: ipc.TestPausedPayload) => Promise<ipc.ResumePayload>;
+ onTestPaused: (payload: ipc.TestPausedPayload) => void;
};
export const emtpyTestInfoCallbacks: TestInfoCallbacks = {
onStepBegin: () => {},
onStepEnd: () => {},
onAttach: () => {},
- onTestPaused: () => Promise.reject(new Error('TestInfoImpl not initialized')),
+ onTestPaused: () => {},
};
// Keep step ids globally unique, to avoid cross-test callId collisions on the same playwright instance.
@@ -496,10 +496,8 @@ export class TestInfoImpl implements TestInfo {
async _didFinishTestFunction() {
const shouldPause = (this._workerParams.pauseAtEnd && !this._isFailure()) || (this._workerParams.pauseOnError && this._isFailure());
if (shouldPause) {
- await Promise.race([
- this._callbacks.onTestPaused({ testId: this.testId, errors: this._isFailure() ? this.errors.map(ipc.toTestInfoErrorPayload) : [], status: this.status }),
- this._interruptedPromise,
- ]);
+ this._callbacks.onTestPaused({ testId: this.testId, errors: this._isFailure() ? this.errors.map(ipc.toTestInfoErrorPayload) : [] });
+ await this._interruptedPromise;
}
for (const cb of this._onDidFinishTestFunctionCallbacks)
await cb();
diff --git a/packages/playwright/src/worker/workerMain.ts b/packages/playwright/src/worker/workerMain.ts
index 8703d27a69..7990d21cc1 100644
--- a/packages/playwright/src/worker/workerMain.ts
+++ b/packages/playwright/src/worker/workerMain.ts
@@ -61,7 +61,6 @@ export class WorkerMain extends ProcessRunner {
// These suites still need afterAll hooks to be executed for the proper cleanup.
// Contains dynamic annotations originated by modifiers with a callback, e.g. `test.skip(() => true)`.
private _activeSuites = new Map<testNs.Suite, TestAnnotation[]>();
- private _resumePromise?: ManualPromise<ipc.ResumePayload>;
constructor(params: ipc.WorkerInitParams) {
super();
@@ -285,20 +284,12 @@ export class WorkerMain extends ProcessRunner {
}
}
- resume(payload: ipc.ResumePayload) {
- this._resumePromise?.resolve(payload);
- }
-
private async _runTest(test: testNs.TestCase, retry: number, nextTest: testNs.TestCase | undefined) {
const testInfo = new TestInfoImpl(this._config, this._project, this._params, test, retry, {
onStepBegin: payload => this.dispatchEvent('stepBegin', payload),
onStepEnd: payload => this.dispatchEvent('stepEnd', payload),
onAttach: payload => this.dispatchEvent('attach', payload),
- onTestPaused: payload => {
- this._resumePromise = new ManualPromise();
- this.dispatchEvent('testPaused', payload);
- return this._resumePromise;
- },
+ onTestPaused: payload => this.dispatchEvent('testPaused', payload),
});
const processAnnotation = (annotation: TestAnnotation) => {
testInfo.annotations.push(annotation);
diff --git a/tests/playwright-test/bun-expectations.conf b/tests/playwright-test/bun-expectations.conf
index abcecbe150..d0c6d086d0 100644
--- a/tests/playwright-test/bun-expectations.conf
+++ b/tests/playwright-test/bun-expectations.conf
@@ -47,12 +47,6 @@ list-mode.spec.ts > should report errors with location [skip]
reporter.spec.ts > created > onError should have code snippet [skip]
reporter.spec.ts > merged > onError should have code snippet [skip]
-# Bun formats stack frames differently.
-reporter-line.spec.ts > onTestPaused > pause at end - error in teardown [skip]
-reporter-line.spec.ts > onTestPaused > pause on error [skip]
-reporter-list.spec.ts > onTestPaused > pause at end - error in teardown [skip]
-reporter-list.spec.ts > onTestPaused > pause on error [skip]
-
# Bun does not report the import stack of parse errors.
loader.spec.ts > should return the location of a syntax error with deep stack [skip]
diff --git a/tests/playwright-test/pause-at-end.spec.ts b/tests/playwright-test/pause-at-end.spec.ts
deleted file mode 100644
index 06f3a9ca34..0000000000
--- a/tests/playwright-test/pause-at-end.spec.ts
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { TestCase, TestResult, TestStep } from '../../packages/playwright-test/reporter';
-import { ReporterV2 } from '../../packages/playwright/src/reporters/reporterV2';
-import { test, expect } from './playwright-test-fixtures';
-
-test.describe.configure({ mode: 'parallel' });
-
-class LocationReporter implements ReporterV2 {
- private _foundErrors = 0;
- version() {
- return 'v2' as const;
- }
- onStepBegin(test: TestCase, result: TestResult, step: TestStep): void {
- if (step.title === 'Paused') {
- console.log(`%%onStepBegin: ${step.titlePath().join(' > ')} at :${step.location?.line}:${step.location?.column}`);
- this._printErrors(result);
- }
- }
- async onTestPaused(test: TestCase, result: TestResult) {
- if (result.error)
- console.log(`%%onTestPaused on error at :${result.error.location?.line}:${result.error.location?.column}`);
- else
- console.log(`%%onTestPaused at end`);
- this._printErrors(result);
- if (process.env.SIGINT_AFTER_PAUSE) {
- console.log('%%SIGINT');
- process.kill(process.pid, 'SIGINT');
- await new Promise(() => {});
- }
- }
- onStepEnd(test: TestCase, result: TestResult, step: TestStep): void {
- if (step.title === 'Paused') {
- console.log(`%%onStepEnd: ${step.titlePath().join(' > ')}`);
- this._printErrors(result);
- }
- }
- onTestEnd(test: TestCase, result: TestResult): void {
- console.log('%%onTestEnd');
- this._printErrors(result);
- }
- onStdOut(chunk: string | Buffer) {
- console.log(chunk);
- }
- private _printErrors(result: TestResult) {
- for (const [index, error] of result.errors.entries()) {
- if (index >= this._foundErrors)
- console.log(`%%result.errors[${index}] at :${error.location?.line}:${error.location?.column}`);
- }
- this._foundErrors = result.errors.length;
- }
-}
-
-test('--pause should pause at end', async ({ runInlineTest }) => {
- const result = await runInlineTest({
- 'location-reporter.js': `export default ${LocationReporter}`,
- 'playwright.config.js': `
- module.exports = { reporter: './location-reporter.js' };
- `,
- 'a.test.js': `
- import { test, expect } from '@playwright/test';
- test('pass', () => {
- });
- test.afterEach(() => {
- console.log('%%teardown');
- });
- `
- }, {}, { PWPAUSE: '1' });
- expect(result.outputLines).toEqual([
- 'onTestPaused at end',
- 'teardown',
- 'onTestEnd',
- ]);
-});
-
-test('--pause should pause at end with setup project', async ({ runInlineTest }) => {
- const result = await runInlineTest({
- 'location-reporter.js': `export default ${LocationReporter}`,
- 'playwright.config.js': `
- module.exports = {
- reporter: './location-reporter.js',
- projects: [
- { name: 'setup', testMatch: /setup\\.test\\.js/ },
- { name: 'main', dependencies: ['setup'] }
- ]
- };
- `,
- 'setup.test.js': `
- import { test } from '@playwright/test';
- test('setup', () => {
- });
- `,
- 'a.test.js': `
- import { test, expect } from '@playwright/test';
- test('pass', () => {
- console.log('main test started');
- });
- `
- }, {}, { PWPAUSE: '1' });
- expect(result.outputLines).toContain('onTestPaused at end');
-});
-
-test('--pause should pause on error', async ({ runInlineTest, mergeReports }) => {
- const result = await runInlineTest({
- 'location-reporter.js': `export default ${LocationReporter}`,
- 'playwright.config.js': `
- module.exports = { reporter: [['./location-reporter.js'], ['blob']] };
- `,
- 'a.test.js': `
- import { test, expect } from '@playwright/test';
- test('pass', () => {
- expect.soft(1).toBe(2);
- expect(2).toBe(3);
- console.log('%%after error');
- });
- `
- }, {}, { PWPAUSE: '1' });
- expect(result.outputLines).toEqual([
- 'onTestPaused on error at :4:24',
- 'result.errors[0] at :4:24',
- 'result.errors[1] at :5:19',
- 'onTestEnd',
- ]);
-
- const merged = await mergeReports('blob-report', undefined, { additionalArgs: ['--reporter', 'location-reporter.js'] });
- expect(merged.outputLines, 'merge reporter doesnt get onTestPaused').toEqual([
- 'onTestEnd',
- 'result.errors[0] at :4:24',
- 'result.errors[1] at :5:19',
- ]);
-});
-
-test('SIGINT after pause at end should still run teardown', async ({ runInlineTest }) => {
- test.skip(process.platform === 'win32', 'no SIGINT on windows');
- const result = await runInlineTest({
- 'location-reporter.js': `export default ${LocationReporter}`,
- 'playwright.config.js': `
- module.exports = { reporter: './location-reporter.js' };
- `,
- 'a.test.js': `
- import { test, expect } from '@playwright/test';
- test('pass', () => {
- });
- test.afterEach(() => {
- console.log('%%teardown');
- });
- `
- }, {}, { PWPAUSE: '1', SIGINT_AFTER_PAUSE: '1' });
- expect(result.outputLines).toEqual([
- 'onTestPaused at end',
- 'SIGINT',
- 'teardown',
- 'onTestEnd',
- ]);
-});
-
-test('SIGINT after pause on error should still run teardown', async ({ runInlineTest }) => {
- test.skip(process.platform === 'win32', 'no SIGINT on windows');
- const result = await runInlineTest({
- 'location-reporter.js': `export default ${LocationReporter}`,
- 'playwright.config.js': `
- module.exports = { reporter: './location-reporter.js' };
- `,
- 'a.test.js': `
- import { test, expect } from '@playwright/test';
- test('pass', () => {
- expect(2).toBe(3);
- console.log('%%after error');
- });
- test.afterEach(() => {
- console.log('%%teardown');
- });
- `
- }, {}, { PWPAUSE: '1', SIGINT_AFTER_PAUSE: '1' });
- expect(result.outputLines).toEqual([
- 'onTestPaused on error at :4:19',
- 'result.errors[0] at :4:19',
- 'SIGINT',
- 'teardown',
- 'onTestEnd',
- ]);
-});
diff --git a/tests/playwright-test/reporter-line.spec.ts b/tests/playwright-test/reporter-line.spec.ts
index 7abf29c3ae..9680c60062 100644
--- a/tests/playwright-test/reporter-line.spec.ts
+++ b/tests/playwright-test/reporter-line.spec.ts
@@ -15,7 +15,7 @@
*/
import path from 'path';
-import { test, expect, stripAnsi } from './playwright-test-fixtures';
+import { test, expect } from './playwright-test-fixtures';
for (const useIntermediateMergeReport of [false, true] as const) {
test.describe(`${useIntermediateMergeReport ? 'merged' : 'created'}`, () => {
@@ -245,153 +245,3 @@ for (const useIntermediateMergeReport of [false, true] as const) {
});
});
}
-
-test.describe('onTestPaused', () => {
- test.skip(process.platform === 'win32', 'No SIGINT on windows');
-
- test('pause at end', async ({ interactWithTestRunner }) => {
- const runner = await interactWithTestRunner({
- 'a.test.ts': `
- import { test, expect } from '@playwright/test';
- test('foo', async ({}) => {
- });
-
- test.afterEach(() => {
- console.log('Running teardown');
- });
- `,
- }, { reporter: 'line' }, { PW_TEST_DEBUG_REPORTERS: '1', PWPAUSE: '1' });
-
- await runner.waitForOutput('Paused at test end. Press Ctrl+C to end.');
- const { exitCode } = await runner.kill('SIGINT');
- expect(exitCode).toBe(130);
-
- expect(stripAnsi(runner.output)).toEqual(`
-Running 1 test using 1 worker
-
-[1/1] a.test.ts:3:9 › foo
- a.test.ts:3:9 › foo ──────────────────────────────────────────────────────────────────────────────
- Paused at test end. Press Ctrl+C to end.
-
-
-[1/1] a.test.ts:3:9 › foo
-a.test.ts:3:9 › foo
-Running teardown
-
- 1) a.test.ts:3:9 › foo ───────────────────────────────────────────────────────────────────────────
-
- Test was interrupted.
-
-
- 1 interrupted
- a.test.ts:3:9 › foo ────────────────────────────────────────────────────────────────────────────
-`);
- });
-
- test('pause at end - error in teardown', async ({ interactWithTestRunner }) => {
- const runner = await interactWithTestRunner({
- 'a.test.ts': `
- import { test, expect } from '@playwright/test';
- test('foo', async ({}) => {
- });
-
- test.afterEach(() => {
- throw new Error('teardown error');
- });
- `,
- }, { reporter: 'line' }, { PW_TEST_DEBUG_REPORTERS: '1', PWPAUSE: '1' });
-
- await runner.waitForOutput('Paused at test end. Press Ctrl+C to end.');
- const { exitCode } = await runner.kill('SIGINT');
- expect(exitCode).toBe(130);
-
- expect(stripAnsi(runner.output)).toEqual(`
-Running 1 test using 1 worker
-
-[1/1] a.test.ts:3:9 › foo
- a.test.ts:3:9 › foo ──────────────────────────────────────────────────────────────────────────────
- Paused at test end. Press Ctrl+C to end.
-
-
-[1/1] a.test.ts:3:9 › foo
- 1) a.test.ts:3:9 › foo ───────────────────────────────────────────────────────────────────────────
-
- Test was interrupted.
-
- Error: teardown error
-
- 5 |
- 6 | test.afterEach(() => {
- > 7 | throw new Error('teardown error');
- | ^
- 8 | });
- 9 |
- at ${test.info().outputPath('a.test.ts')}:7:17
-
- Error Context: test-results/a-foo/error-context.md
-
-
- 1 interrupted
- a.test.ts:3:9 › foo ────────────────────────────────────────────────────────────────────────────
-`);
- });
-
- test('pause on error', async ({ interactWithTestRunner }) => {
- const runner = await interactWithTestRunner({
- 'a.test.ts': `
- import { test, expect } from '@playwright/test';
- test('fails', async ({}) => {
- expect.soft(2).toBe(3);
- expect(3).toBe(4);
- });
- `,
- }, { reporter: 'line' }, { PW_TEST_DEBUG_REPORTERS: '1', PWPAUSE: '1' });
-
- await runner.waitForOutput('Paused on error. Press Ctrl+C to end.');
- const { exitCode } = await runner.kill('SIGINT');
- expect(exitCode).toBe(130);
-
- expect(stripAnsi(runner.output)).toEqual(`
-Running 1 test using 1 worker
-
-[1/1] a.test.ts:3:9 › fails
- 1) a.test.ts:3:9 › fails ─────────────────────────────────────────────────────────────────────────
-
- Error: expect(received).toBe(expected) // Object.is equality
-
- Expected: 3
- Received: 2
-
- 2 | import { test, expect } from '@playwright/test';
- 3 | test('fails', async ({}) => {
- > 4 | expect.soft(2).toBe(3);
- | ^
- 5 | expect(3).toBe(4);
- 6 | });
- 7 |
- at ${test.info().outputPath('a.test.ts')}:4:26
-
- Error: expect(received).toBe(expected) // Object.is equality
-
- Expected: 4
- Received: 3
-
- 3 | test('fails', async ({}) => {
- 4 | expect.soft(2).toBe(3);
- > 5 | expect(3).toBe(4);
- | ^
- 6 | });
- 7 |
- at ${test.info().outputPath('a.test.ts')}:5:21
-
- Paused on error. Press Ctrl+C to end.
-
-
-[1/1] a.test.ts:3:9 › fails
-
-
- 1 failed
- a.test.ts:3:9 › fails ──────────────────────────────────────────────────────────────────────────
-`);
- });
-});
diff --git a/tests/playwright-test/reporter-list.spec.ts b/tests/playwright-test/reporter-list.spec.ts
index 1f76920ad1..43da2ad41f 100644
--- a/tests/playwright-test/reporter-list.spec.ts
+++ b/tests/playwright-test/reporter-list.spec.ts
@@ -530,143 +530,6 @@ for (const useIntermediateMergeReport of [false, true] as const) {
});
}
-test.describe('onTestPaused', () => {
- test.skip(process.platform === 'win32', 'No SIGINT on windows');
-
- test('pause at end', async ({ interactWithTestRunner }) => {
- const runner = await interactWithTestRunner({
- 'a.test.ts': `
- import { test, expect } from '@playwright/test';
- test('foo', async ({}) => {
- });
-
- test.afterEach(() => {
- console.log('Running teardown');
- });
- `,
- }, { reporter: 'list' }, { PW_TEST_DEBUG_REPORTERS: '1', PWPAUSE: '1' });
-
- await runner.waitForOutput('Paused at test end. Press Ctrl+C to end.');
- const { exitCode } = await runner.kill('SIGINT');
- expect(exitCode).toBe(130);
-
- const output = stripAnsi(runner.output).replace(/\d+(\.\d+)?m?s/g, 'Xms');
- expect(output).toEqual(`
-Running 1 test using 1 worker
-
-#0 : ${POSITIVE_STATUS_MARK} 1 a.test.ts:3:9 › foo (Xms)
-#1 : Paused at test end. Press Ctrl+C to end.
-Running teardown
-
- 1 interrupted
- a.test.ts:3:9 › foo ────────────────────────────────────────────────────────────────────────────
-`);
- });
-
- test('pause at end - error in teardown', async ({ interactWithTestRunner }) => {
- const runner = await interactWithTestRunner({
- 'a.test.ts': `
- import { test, expect } from '@playwright/test';
- test('foo', async ({}) => {
- });
-
- test.afterEach(() => {
- throw new Error('teardown error');
- });
- `,
- }, { reporter: 'list' }, { PW_TEST_DEBUG_REPORTERS: '1', PWPAUSE: '1' });
-
- await runner.waitForOutput('Paused at test end. Press Ctrl+C to end.');
- const { exitCode } = await runner.kill('SIGINT');
- expect(exitCode).toBe(130);
-
- const output = stripAnsi(runner.output).replace(/\d+(\.\d+)?m?s/g, 'Xms');
- expect(output).toEqual(`
-Running 1 test using 1 worker
-
-#0 : ${POSITIVE_STATUS_MARK} 1 a.test.ts:3:9 › foo (Xms)
-#1 : Paused at test end. Press Ctrl+C to end.
-
-
- 1) a.test.ts:3:9 › foo ───────────────────────────────────────────────────────────────────────────
-
- Test was interrupted.
-
- Error: teardown error
-
- 5 |
- 6 | test.afterEach(() => {
- > 7 | throw new Error('teardown error');
- | ^
- 8 | });
- 9 |
- at ${test.info().outputPath('a.test.ts')}:7:17
-
- Error Context: test-results/a-foo/error-context.md
-
- 1 interrupted
- a.test.ts:3:9 › foo ────────────────────────────────────────────────────────────────────────────
-`);
- });
-
- test('pause on error', async ({ interactWithTestRunner }) => {
- const runner = await interactWithTestRunner({
- 'a.test.ts': `
- import { test, expect } from '@playwright/test';
- test('fails', async ({}) => {
- expect.soft(2).toBe(3);
- expect(3).toBe(4);
- });
- `,
- }, { reporter: 'list' }, { PW_TEST_DEBUG_REPORTERS: '1', PWPAUSE: '1' });
-
- await runner.waitForOutput('Paused on error. Press Ctrl+C to end.');
- const { exitCode } = await runner.kill('SIGINT');
- expect(exitCode).toBe(130);
-
- const output = stripAnsi(runner.output).replace(/\d+(\.\d+)?m?s/g, 'Xms');
- expect(output).toEqual(`
-Running 1 test using 1 worker
-
-#0 : ${NEGATIVE_STATUS_MARK} 1 a.test.ts:3:9 › fails (Xms)
-
- Error: expect(received).toBe(expected) // Object.is equality
-
- Expected: 3
- Received: 2
-
- 2 | import { test, expect } from '@playwright/test';
- 3 | test('fails', async ({}) => {
- > 4 | expect.soft(2).toBe(3);
- | ^
- 5 | expect(3).toBe(4);
- 6 | });
- 7 |
- at ${test.info().outputPath('a.test.ts')}:4:26
-
- Error: expect(received).toBe(expected) // Object.is equality
-
- Expected: 4
- Received: 3
-
- 3 | test('fails', async ({}) => {
- 4 | expect.soft(2).toBe(3);
- > 5 | expect(3).toBe(4);
- | ^
- 6 | });
- 7 |
- at ${test.info().outputPath('a.test.ts')}:5:21
-
-#1 : Paused on error. Press Ctrl+C to end.
-
-
-
- 1 failed
- a.test.ts:3:9 › fails ──────────────────────────────────────────────────────────────────────────
-`);
- });
-});
-
test('strips ansi from test stdout when FORCE_COLOR=0', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.ts': `