chore: revert exposed expect error details on TestError (#33310)

This commit is contained in:
Yury Semikhatsky 2024-10-25 16:20:18 -07:00 committed by GitHub
parent 74e5e5560f
commit 0ace47e7cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 0 additions and 128 deletions

View File

@ -4,54 +4,18 @@
Information about an error thrown during test execution. 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 ## property: TestError.message
* since: v1.10 * since: v1.10
- type: ?<[string]> - type: ?<[string]>
Error message. Set when [Error] (or its subclass) has been thrown. 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 ## property: TestError.stack
* since: v1.10 * since: v1.10
- type: ?<[string]> - type: ?<[string]>
Error stack. Set when [Error] (or its subclass) has been thrown. 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 ## property: TestError.value
* since: v1.10 * since: v1.10
- type: ?<[string]> - type: ?<[string]>

View File

@ -39,10 +39,6 @@ export type MatcherResult<E, A> = {
actual?: A; actual?: A;
log?: string[]; log?: string[];
timeout?: number; timeout?: number;
locator?: string;
printedReceived?: string;
printedExpected?: string;
printedDiff?: string;
suggestedRebaseline?: string; suggestedRebaseline?: string;
}; };

View File

@ -73,7 +73,5 @@ export async function toBeTruthy(
expected, expected,
log, log,
timeout: timedOut ? timeout : undefined, timeout: timedOut ? timeout : undefined,
...(printedReceived ? { printedReceived } : {}),
...(printedExpected ? { printedExpected } : {}),
}; };
} }

View File

@ -83,8 +83,5 @@ export async function toEqual<T>(
pass, pass,
log, log,
timeout: timedOut ? timeout : undefined, timeout: timedOut ? timeout : undefined,
...(printedReceived ? { printedReceived } : {}),
...(printedExpected ? { printedExpected } : {}),
...(printedDiff ? { printedDiff } : {}),
}; };
} }

View File

@ -194,10 +194,6 @@ class SnapshotHelper {
pass, pass,
message: () => message, message: () => message,
log, 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; return Object.fromEntries(Object.entries(unfiltered).filter(([_, v]) => v !== undefined)) as ImageMatcherResult;
} }

View File

@ -118,10 +118,5 @@ export async function toMatchText(
actual: received, actual: received,
log, log,
timeout: timedOut ? timeout : undefined, timeout: timedOut ? timeout : undefined,
// eslint-disable-next-line @typescript-eslint/no-base-to-string
locator: receiver.toString(),
...(printedReceived ? { printedReceived } : {}),
...(printedExpected ? { printedExpected } : {}),
...(printedDiff ? { printedDiff } : {}),
}; };
} }

View File

@ -26,13 +26,6 @@ export const kOutputSymbol = Symbol('output');
type ErrorDetails = { type ErrorDetails = {
message: string; message: string;
location?: Location; location?: Location;
timeout?: number;
matcherName?: string;
locator?: string;
expected?: string;
received?: string;
log?: string[];
snippet?: string;
}; };
type TestSummary = { type TestSummary = {
@ -362,13 +355,6 @@ export function formatResultFailure(test: TestCase, result: TestResult, initialI
errorDetails.push({ errorDetails.push({
message: indent(formattedError.message, initialIndent), message: indent(formattedError.message, initialIndent),
location: formattedError.location, 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; return errorDetails;

View File

@ -554,41 +554,16 @@ export interface TestCase {
* Information about an error thrown during test execution. * Information about an error thrown during test execution.
*/ */
export interface TestError { export interface TestError {
/**
* Expected value formatted as a human-readable string.
*/
expected?: string;
/** /**
* Error location in the source code. * Error location in the source code.
*/ */
location?: Location; 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. * Error message. Set when [Error] (or its subclass) has been thrown.
*/ */
message?: string; message?: string;
/**
* Received value formatted as a human-readable string.
*/
received?: string;
/** /**
* Source code snippet with highlighted error. * Source code snippet with highlighted error.
*/ */
@ -599,11 +574,6 @@ export interface TestError {
*/ */
stack?: string; 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. * The value that was thrown. Set when anything except the [Error] (or its subclass) has been thrown.
*/ */

View File

@ -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); const e = await expect(locator).toHaveText(/Text2/, { timeout: 1 }).catch(e => e);
e.matcherResult.message = stripAnsi(e.matcherResult.message); e.matcherResult.message = stripAnsi(e.matcherResult.message);
e.matcherResult.printedDiff = stripAnsi(e.matcherResult.printedDiff);
expect.soft(e.matcherResult).toEqual({ expect.soft(e.matcherResult).toEqual({
actual: 'Text content', actual: 'Text content',
expected: /Text2/, expected: /Text2/,
message: expect.stringContaining(`Timed out 1ms waiting for expect(locator).toHaveText(expected)`), message: expect.stringContaining(`Timed out 1ms waiting for expect(locator).toHaveText(expected)`),
name: 'toHaveText', name: 'toHaveText',
pass: false, pass: false,
locator: `locator('#node')`,
printedDiff: `Expected pattern: /Text2/
Received string: \"Text content\"`,
log: expect.any(Array), log: expect.any(Array),
timeout: 1, timeout: 1,
}); });
@ -50,17 +46,12 @@ Call log`);
{ {
const e = await expect(locator).not.toHaveText(/Text/, { timeout: 1 }).catch(e => e); const e = await expect(locator).not.toHaveText(/Text/, { timeout: 1 }).catch(e => e);
e.matcherResult.message = stripAnsi(e.matcherResult.message); 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({ expect.soft(e.matcherResult).toEqual({
actual: 'Text content', actual: 'Text content',
expected: /Text/, expected: /Text/,
message: expect.stringContaining(`Timed out 1ms waiting for expect(locator).not.toHaveText(expected)`), message: expect.stringContaining(`Timed out 1ms waiting for expect(locator).not.toHaveText(expected)`),
name: 'toHaveText', name: 'toHaveText',
pass: true, pass: true,
locator: `locator('#node')`,
printedExpected: 'Expected pattern: not /Text/',
printedReceived: `Received string: \"Text content\"`,
log: expect.any(Array), log: expect.any(Array),
timeout: 1, timeout: 1,
}); });
@ -88,8 +79,6 @@ test('toBeTruthy-based assertions should have matcher result', async ({ page })
name: 'toBeVisible', name: 'toBeVisible',
pass: false, pass: false,
log: expect.any(Array), log: expect.any(Array),
printedExpected: 'Expected: visible',
printedReceived: 'Received: <element(s) not found>',
timeout: 1, timeout: 1,
}); });
@ -112,8 +101,6 @@ Call log`);
name: 'toBeVisible', name: 'toBeVisible',
pass: true, pass: true,
log: expect.any(Array), log: expect.any(Array),
printedExpected: 'Expected: not visible',
printedReceived: 'Received: visible',
timeout: 1, 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); const e = await expect(page.locator('#node2')).toHaveCount(1, { timeout: 1 }).catch(e => e);
e.matcherResult.message = stripAnsi(e.matcherResult.message); e.matcherResult.message = stripAnsi(e.matcherResult.message);
e.matcherResult.printedDiff = stripAnsi(e.matcherResult.printedDiff);
expect.soft(e.matcherResult).toEqual({ expect.soft(e.matcherResult).toEqual({
actual: 0, actual: 0,
expected: 1, expected: 1,
@ -141,8 +127,6 @@ test('toEqual-based assertions should have matcher result', async ({ page }) =>
name: 'toHaveCount', name: 'toHaveCount',
pass: false, pass: false,
log: expect.any(Array), log: expect.any(Array),
printedDiff: `Expected: 1
Received: 0`,
timeout: 1, timeout: 1,
}); });
@ -157,8 +141,6 @@ Call log`);
{ {
const e = await expect(page.locator('#node')).not.toHaveCount(1, { timeout: 1 }).catch(e => e); const e = await expect(page.locator('#node')).not.toHaveCount(1, { timeout: 1 }).catch(e => e);
e.matcherResult.message = stripAnsi(e.matcherResult.message); 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({ expect.soft(e.matcherResult).toEqual({
actual: 1, actual: 1,
expected: 1, expected: 1,
@ -166,8 +148,6 @@ Call log`);
name: 'toHaveCount', name: 'toHaveCount',
pass: true, pass: true,
log: expect.any(Array), log: expect.any(Array),
printedExpected: `Expected: not 1`,
printedReceived: `Received: 1`,
timeout: 1, timeout: 1,
}); });
@ -197,8 +177,6 @@ test('toBeChecked({ checked: false }) should have expected: false', async ({ pag
name: 'toBeChecked', name: 'toBeChecked',
pass: false, pass: false,
log: expect.any(Array), log: expect.any(Array),
printedExpected: 'Expected: checked',
printedReceived: 'Received: unchecked',
timeout: 1, timeout: 1,
}); });
@ -221,8 +199,6 @@ Call log`);
name: 'toBeChecked', name: 'toBeChecked',
pass: true, pass: true,
log: expect.any(Array), log: expect.any(Array),
printedExpected: 'Expected: not checked',
printedReceived: 'Received: checked',
timeout: 1, timeout: 1,
}); });
@ -245,8 +221,6 @@ Call log`);
name: 'toBeChecked', name: 'toBeChecked',
pass: false, pass: false,
log: expect.any(Array), log: expect.any(Array),
printedExpected: 'Expected: unchecked',
printedReceived: 'Received: checked',
timeout: 1, timeout: 1,
}); });
@ -269,8 +243,6 @@ Call log`);
name: 'toBeChecked', name: 'toBeChecked',
pass: true, pass: true,
log: expect.any(Array), log: expect.any(Array),
printedExpected: 'Expected: not unchecked',
printedReceived: 'Received: unchecked',
timeout: 1, timeout: 1,
}); });
@ -299,8 +271,6 @@ test('toHaveScreenshot should populate matcherResult', async ({ page, server, is
name: 'toHaveScreenshot', name: 'toHaveScreenshot',
pass: false, pass: false,
log: expect.any(Array), 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) expect.soft(stripAnsi(e.toString())).toContain(`Error: expect(page).toHaveScreenshot(expected)