Skip to content

Commit

Permalink
Revert "chore: expose expect error details on TestError (microsoft#33183
Browse files Browse the repository at this point in the history
)"

This reverts commit aebceb3.
  • Loading branch information
yury-s committed Oct 25, 2024
1 parent 4facda8 commit d4ac639
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 128 deletions.
36 changes: 0 additions & 36 deletions docs/src/test-reporter-api/class-testerror.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand Down
4 changes: 0 additions & 4 deletions packages/playwright/src/matchers/matcherHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
2 changes: 0 additions & 2 deletions packages/playwright/src/matchers/toBeTruthy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,5 @@ export async function toBeTruthy(
expected,
log,
timeout: timedOut ? timeout : undefined,
...(printedReceived ? { printedReceived } : {}),
...(printedExpected ? { printedExpected } : {}),
};
}
3 changes: 0 additions & 3 deletions packages/playwright/src/matchers/toEqual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,5 @@ export async function toEqual<T>(
pass,
log,
timeout: timedOut ? timeout : undefined,
...(printedReceived ? { printedReceived } : {}),
...(printedExpected ? { printedExpected } : {}),
...(printedDiff ? { printedDiff } : {}),
};
}
4 changes: 0 additions & 4 deletions packages/playwright/src/matchers/toMatchSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 0 additions & 5 deletions packages/playwright/src/matchers/toMatchText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {}),
};
}
14 changes: 0 additions & 14 deletions packages/playwright/src/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -362,13 +355,6 @@ export function formatResultFailure(test: TestCase, result: TestResult, initialI
errorDetails.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;
Expand Down
30 changes: 0 additions & 30 deletions packages/playwright/types/testReporter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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.
*/
Expand Down
30 changes: 0 additions & 30 deletions tests/page/expect-matcher-result.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand All @@ -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,
});
Expand Down Expand Up @@ -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,
});

Expand All @@ -112,8 +101,6 @@ Call log`);
name: 'toBeVisible',
pass: true,
log: expect.any(Array),
printedExpected: 'Expected: not visible',
printedReceived: 'Received: visible',
timeout: 1,
});

Expand All @@ -133,16 +120,13 @@ 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,
message: expect.stringContaining(`Timed out 1ms waiting for expect(locator).toHaveCount(expected)`),
name: 'toHaveCount',
pass: false,
log: expect.any(Array),
printedDiff: `Expected: 1
Received: 0`,
timeout: 1,
});

Expand All @@ -157,17 +141,13 @@ 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,
message: expect.stringContaining(`Timed out 1ms waiting for expect(locator).not.toHaveCount(expected)`),
name: 'toHaveCount',
pass: true,
log: expect.any(Array),
printedExpected: `Expected: not 1`,
printedReceived: `Received: 1`,
timeout: 1,
});

Expand Down Expand Up @@ -197,8 +177,6 @@ test('toBeChecked({ checked: false }) should have expected: false', async ({ pag
name: 'toBeChecked',
pass: false,
log: expect.any(Array),
printedExpected: 'Expected: checked',
printedReceived: 'Received: unchecked',
timeout: 1,
});

Expand All @@ -221,8 +199,6 @@ Call log`);
name: 'toBeChecked',
pass: true,
log: expect.any(Array),
printedExpected: 'Expected: not checked',
printedReceived: 'Received: checked',
timeout: 1,
});

Expand All @@ -245,8 +221,6 @@ Call log`);
name: 'toBeChecked',
pass: false,
log: expect.any(Array),
printedExpected: 'Expected: unchecked',
printedReceived: 'Received: checked',
timeout: 1,
});

Expand All @@ -269,8 +243,6 @@ Call log`);
name: 'toBeChecked',
pass: true,
log: expect.any(Array),
printedExpected: 'Expected: not unchecked',
printedReceived: 'Received: unchecked',
timeout: 1,
});

Expand Down Expand Up @@ -299,8 +271,6 @@ test('toHaveScreenshot should populate matcherResult', async ({ page, server, is
name: '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)
Expand Down

0 comments on commit d4ac639

Please sign in to comment.