Skip to content

Commit 8929269

Browse files
committed
timeout vs timedOut
1 parent a6315ec commit 8929269

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

packages/playwright/src/matchers/matcherHint.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type MatcherMessageDetails = {
2929
printedExpected?: string;
3030
printedReceived?: string;
3131
printedDiff?: string;
32+
timedOut?: boolean;
3233
timeout?: number;
3334
errorMessage?: string;
3435
log?: string[];
@@ -59,7 +60,7 @@ export function formatMatcherMessage(state: ExpectMatcherState, details: Matcher
5960
message += details.printedExpected + '\n';
6061
if (details.printedReceived)
6162
message += details.printedReceived + '\n';
62-
if (details.timeout)
63+
if (details.timedOut && details.timeout)
6364
message += `Timeout: ${align ? ' ' : ''}${details.timeout}ms\n`;
6465
if (details.printedDiff)
6566
message += details.printedDiff + '\n';

packages/playwright/src/matchers/toBeTruthy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export async function toBeTruthy(
6161
matcherName,
6262
expectation: arg,
6363
locator,
64-
timeout: timedOut ? timeout : undefined,
64+
timeout,
65+
timedOut,
6566
printedExpected,
6667
printedReceived,
6768
errorMessage,

packages/playwright/src/matchers/toEqual.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export async function toEqual<T>(
8989
matcherName,
9090
expectation: 'expected',
9191
locator,
92-
timeout: timedOut ? timeout : undefined,
92+
timeout,
93+
timedOut,
9394
printedExpected,
9495
printedReceived,
9596
printedDiff,

packages/playwright/src/matchers/toHaveURL.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function toHaveURLMessage(
9090
expected: Function,
9191
received: string | undefined,
9292
pass: boolean,
93-
didTimeout: boolean,
93+
timedOut: boolean,
9494
timeout: number,
9595
): string {
9696
const receivedString = received || '';
@@ -115,7 +115,8 @@ function toHaveURLMessage(
115115
return formatMatcherMessage(state, {
116116
matcherName,
117117
expectation: 'expected',
118-
timeout: didTimeout ? timeout : undefined,
118+
timeout,
119+
timedOut,
119120
printedExpected,
120121
printedReceived,
121122
printedDiff,

packages/playwright/src/matchers/toMatchAriaSnapshot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ export async function toMatchAriaSnapshot(
104104
matcherName,
105105
expectation: 'expected',
106106
locator,
107-
timeout: timedOut ? timeout : undefined,
107+
timeout,
108+
timedOut,
108109
printedExpected,
109110
printedReceived,
110111
printedDiff,

packages/playwright/src/matchers/toMatchSnapshot.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export async function toHaveScreenshot(
381381
// We tried re-generating new snapshot but failed.
382382
// This can be due to e.g. spinning animation, so we want to show it as a diff.
383383
if (errorMessage) {
384-
const header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout: timedOut ? timeout : undefined });
384+
const header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout, timedOut });
385385
return helper.handleDifferent(actual, undefined, previous, diff, header, errorMessage, log, this._stepInfo);
386386
}
387387

@@ -416,12 +416,12 @@ export async function toHaveScreenshot(
416416
if (helper.updateSnapshots === 'changed' || helper.updateSnapshots === 'all') {
417417
if (actual)
418418
return writeFiles(actual);
419-
let header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout: timedOut ? timeout : undefined });
419+
let header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout, timedOut });
420420
header += ' Failed to re-generate expected.\n';
421421
return helper.handleDifferent(actual, expectScreenshotOptions.expected, previous, diff, header, errorMessage, log, this._stepInfo);
422422
}
423423

424-
const header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout: timedOut ? timeout : undefined });
424+
const header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout, timedOut });
425425
return helper.handleDifferent(actual, expectScreenshotOptions.expected, previous, diff, header, errorMessage, log, this._stepInfo);
426426
}
427427

packages/playwright/src/matchers/toMatchText.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export async function toMatchText(
9393
matcherName,
9494
expectation: 'expected',
9595
locator,
96-
timeout: timedOut ? timeout : undefined,
96+
timeout,
97+
timedOut,
9798
printedExpected,
9899
printedReceived,
99100
printedDiff,

0 commit comments

Comments
 (0)