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
chore: revert exposed expect error details on TestError (#33310)
Yury Semikhatsky0ace47e7cf6b
diff --git a/docs/src/test-reporter-api/class-testerror.md b/docs/src/test-reporter-api/class-testerror.mdindex 8e76d6f595..7a872c63fc 100644--- a/docs/src/test-reporter-api/class-testerror.md+++ b/docs/src/test-reporter-api/class-testerror.md@@ -4,54 +4,18 @@Information about an error thrown during test execution.-## property: TestError.expected-* since: v1.49-- type: ?<[string]>--Expected value formatted as a human-readable string.--## property: TestError.locator-* since: v1.49-- type: ?<[string]>--Receiver's locator.--## property: TestError.log-* since: v1.49-- type: ?<[Array]<[string]>>--Call log.--## property: TestError.matcherName-* since: v1.49-- type: ?<[string]>--Expect matcher name.-## property: TestError.message* since: v1.10- type: ?<[string]>Error message. Set when [Error] (or its subclass) has been thrown.-## property: TestError.received-* since: v1.49-- type: ?<[string]>--Received value formatted as a human-readable string.-## property: TestError.stack* since: v1.10- type: ?<[string]>Error stack. Set when [Error] (or its subclass) has been thrown.-## property: TestError.timeout-* since: v1.49-- type: ?<[int]>--Timeout in milliseconds, if the error was caused by a timeout.-## property: TestError.value* since: v1.10- type: ?<[string]>diff --git a/packages/playwright/src/matchers/matcherHint.ts b/packages/playwright/src/matchers/matcherHint.tsindex fc195474e7..dc4264d56b 100644--- a/packages/playwright/src/matchers/matcherHint.ts+++ b/packages/playwright/src/matchers/matcherHint.ts@@ -39,10 +39,6 @@ export type MatcherResult<E, A> = {actual?: A;log?: string[];timeout?: number;- locator?: string;- printedReceived?: string;- printedExpected?: string;- printedDiff?: string;suggestedRebaseline?: string;};diff --git a/packages/playwright/src/matchers/toBeTruthy.ts b/packages/playwright/src/matchers/toBeTruthy.tsindex 8902a14eea..abe00a8852 100644--- a/packages/playwright/src/matchers/toBeTruthy.ts+++ b/packages/playwright/src/matchers/toBeTruthy.ts@@ -73,7 +73,5 @@ export async function toBeTruthy(expected,log,timeout: timedOut ? timeout : undefined,- ...(printedReceived ? { printedReceived } : {}),- ...(printedExpected ? { printedExpected } : {}),};}diff --git a/packages/playwright/src/matchers/toEqual.ts b/packages/playwright/src/matchers/toEqual.tsindex f75caf87f5..bb0f4e147e 100644--- a/packages/playwright/src/matchers/toEqual.ts+++ b/packages/playwright/src/matchers/toEqual.ts@@ -83,8 +83,5 @@ export async function toEqual<T>(pass,log,timeout: timedOut ? timeout : undefined,- ...(printedReceived ? { printedReceived } : {}),- ...(printedExpected ? { printedExpected } : {}),- ...(printedDiff ? { printedDiff } : {}),};}diff --git a/packages/playwright/src/matchers/toMatchSnapshot.ts b/packages/playwright/src/matchers/toMatchSnapshot.tsindex 24b387f3ea..374fba3db5 100644--- a/packages/playwright/src/matchers/toMatchSnapshot.ts+++ b/packages/playwright/src/matchers/toMatchSnapshot.ts@@ -194,10 +194,6 @@ class SnapshotHelper {pass,message: () => message,log,- // eslint-disable-next-line @typescript-eslint/no-base-to-string- ...(this.locator ? { locator: this.locator.toString() } : {}),- printedExpected: this.expectedPath,- printedReceived: this.actualPath,};return Object.fromEntries(Object.entries(unfiltered).filter(([_, v]) => v !== undefined)) as ImageMatcherResult;}diff --git a/packages/playwright/src/matchers/toMatchText.ts b/packages/playwright/src/matchers/toMatchText.tsindex 76ed48af1e..2f8bc34b21 100644--- a/packages/playwright/src/matchers/toMatchText.ts+++ b/packages/playwright/src/matchers/toMatchText.ts@@ -118,10 +118,5 @@ export async function toMatchText(actual: received,log,timeout: timedOut ? timeout : undefined,- // eslint-disable-next-line @typescript-eslint/no-base-to-string- locator: receiver.toString(),- ...(printedReceived ? { printedReceived } : {}),- ...(printedExpected ? { printedExpected } : {}),- ...(printedDiff ? { printedDiff } : {}),};}diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.tsindex 66f78bfdc9..fb0930c545 100644--- a/packages/playwright/src/reporters/base.ts+++ b/packages/playwright/src/reporters/base.ts@@ -26,13 +26,6 @@ export const kOutputSymbol = Symbol('output');type ErrorDetails = {message: string;location?: Location;- timeout?: number;- matcherName?: string;- locator?: string;- expected?: string;- received?: string;- log?: string[];- snippet?: string;};type TestSummary = {@@ -362,13 +355,6 @@ export function formatResultFailure(test: TestCase, result: TestResult, initialIerrorDetails.push({message: indent(formattedError.message, initialIndent),location: formattedError.location,- timeout: error.timeout,- matcherName: error.matcherName,- locator: error.locator,- expected: error.expected,- received: error.received,- log: error.log,- snippet: error.snippet,});}return errorDetails;diff --git a/packages/playwright/types/testReporter.d.ts b/packages/playwright/types/testReporter.d.tsindex 5663f92f98..a9d1f020ae 100644--- a/packages/playwright/types/testReporter.d.ts+++ b/packages/playwright/types/testReporter.d.ts@@ -554,41 +554,16 @@ export interface TestCase {* Information about an error thrown during test execution.*/export interface TestError {- /**- * Expected value formatted as a human-readable string.- */- expected?: string;-/*** Error location in the source code.*/location?: Location;- /**- * Receiver's locator.- */- locator?: string;-- /**- * Call log.- */- log?: Array<string>;-- /**- * Expect matcher name.- */- matcherName?: string;-/*** Error message. Set when [Error] (or its subclass) has been thrown.*/message?: string;- /**- * Received value formatted as a human-readable string.- */- received?: string;-/*** Source code snippet with highlighted error.*/@@ -599,11 +574,6 @@ export interface TestError {*/stack?: string;- /**- * Timeout in milliseconds, if the error was caused by a timeout.- */- timeout?: number;-/*** The value that was thrown. Set when anything except the [Error] (or its subclass) has been thrown.*/diff --git a/tests/page/expect-matcher-result.spec.ts b/tests/page/expect-matcher-result.spec.tsindex fe983c6f63..20dd0a102b 100644--- a/tests/page/expect-matcher-result.spec.ts+++ b/tests/page/expect-matcher-result.spec.ts@@ -24,16 +24,12 @@ test('toMatchText-based assertions should have matcher result', async ({ page }){const e = await expect(locator).toHaveText(/Text2/, { timeout: 1 }).catch(e => e);e.matcherResult.message = stripAnsi(e.matcherResult.message);- e.matcherResult.printedDiff = stripAnsi(e.matcherResult.printedDiff);expect.soft(e.matcherResult).toEqual({actual: 'Text content',expected: /Text2/,message: expect.stringContaining(`Timed out 1ms waiting for expect(locator).toHaveText(expected)`),name: 'toHaveText',pass: false,- locator: `locator('#node')`,- printedDiff: `Expected pattern: /Text2/-Received string: \"Text content\"`,log: expect.any(Array),timeout: 1,});@@ -50,17 +46,12 @@ Call log`);{const e = await expect(locator).not.toHaveText(/Text/, { timeout: 1 }).catch(e => e);e.matcherResult.message = stripAnsi(e.matcherResult.message);- e.matcherResult.printedExpected = stripAnsi(e.matcherResult.printedExpected);- e.matcherResult.printedReceived = stripAnsi(e.matcherResult.printedReceived);expect.soft(e.matcherResult).toEqual({actual: 'Text content',expected: /Text/,message: expect.stringContaining(`Timed out 1ms waiting for expect(locator).not.toHaveText(expected)`),name: 'toHaveText',pass: true,- locator: `locator('#node')`,- printedExpected: 'Expected pattern: not /Text/',- printedReceived: `Received string: \"Text content\"`,log: expect.any(Array),timeout: 1,});@@ -88,8 +79,6 @@ test('toBeTruthy-based assertions should have matcher result', async ({ page })name: 'toBeVisible',pass: false,log: expect.any(Array),- printedExpected: 'Expected: visible',- printedReceived: 'Received: <element(s) not found>',timeout: 1,});@@ -112,8 +101,6 @@ Call log`);name: 'toBeVisible',pass: true,log: expect.any(Array),- printedExpected: 'Expected: not visible',- printedReceived: 'Received: visible',timeout: 1,});@@ -133,7 +120,6 @@ test('toEqual-based assertions should have matcher result', async ({ page }) =>{const e = await expect(page.locator('#node2')).toHaveCount(1, { timeout: 1 }).catch(e => e);e.matcherResult.message = stripAnsi(e.matcherResult.message);- e.matcherResult.printedDiff = stripAnsi(e.matcherResult.printedDiff);expect.soft(e.matcherResult).toEqual({actual: 0,expected: 1,@@ -141,8 +127,6 @@ test('toEqual-based assertions should have matcher result', async ({ page }) =>name: 'toHaveCount',pass: false,log: expect.any(Array),- printedDiff: `Expected: 1-Received: 0`,timeout: 1,});@@ -157,8 +141,6 @@ Call log`);{const e = await expect(page.locator('#node')).not.toHaveCount(1, { timeout: 1 }).catch(e => e);e.matcherResult.message = stripAnsi(e.matcherResult.message);- e.matcherResult.printedExpected = stripAnsi(e.matcherResult.printedExpected);- e.matcherResult.printedReceived = stripAnsi(e.matcherResult.printedReceived);expect.soft(e.matcherResult).toEqual({actual: 1,expected: 1,@@ -166,8 +148,6 @@ Call log`);name: 'toHaveCount',pass: true,log: expect.any(Array),- printedExpected: `Expected: not 1`,- printedReceived: `Received: 1`,timeout: 1,});@@ -197,8 +177,6 @@ test('toBeChecked({ checked: false }) should have expected: false', async ({ pagname: 'toBeChecked',pass: false,log: expect.any(Array),- printedExpected: 'Expected: checked',- printedReceived: 'Received: unchecked',timeout: 1,});@@ -221,8 +199,6 @@ Call log`);name: 'toBeChecked',pass: true,log: expect.any(Array),- printedExpected: 'Expected: not checked',- printedReceived: 'Received: checked',timeout: 1,});@@ -245,8 +221,6 @@ Call log`);name: 'toBeChecked',pass: false,log: expect.any(Array),- printedExpected: 'Expected: unchecked',- printedReceived: 'Received: checked',timeout: 1,});@@ -269,8 +243,6 @@ Call log`);name: 'toBeChecked',pass: true,log: expect.any(Array),- printedExpected: 'Expected: not unchecked',- printedReceived: 'Received: unchecked',timeout: 1,});@@ -299,8 +271,6 @@ test('toHaveScreenshot should populate matcherResult', async ({ page, server, isname: 'toHaveScreenshot',pass: false,log: expect.any(Array),- printedExpected: expect.stringContaining('screenshot-sanity-'),- printedReceived: expect.stringContaining('screenshot-sanity-actual'),});expect.soft(stripAnsi(e.toString())).toContain(`Error: expect(page).toHaveScreenshot(expected)