docs: syntax corrections in expect.extend documentation (#27772)

Signed-off-by: Yury Semikhatsky <yurys@chromium.org>
Co-authored-by: Yury Semikhatsky <yurys@chromium.org>
Co-authored-by: Pavel Feldman <pavel.feldman@gmail.com>
This commit is contained in:
Renan Greca 2023-10-30 22:03:24 +01:00 committed by GitHub
parent afa5cdc53f
commit 7bab19d807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -165,6 +165,7 @@ export { test } from '@playwright/test';
export const expect = baseExpect.extend({ export const expect = baseExpect.extend({
async toHaveAmount(locator: Locator, expected: number, options?: { timeout?: number }) { async toHaveAmount(locator: Locator, expected: number, options?: { timeout?: number }) {
const assertionName = 'toHaveAmount';
let pass: boolean; let pass: boolean;
let matcherResult: any; let matcherResult: any;
try { try {
@ -176,21 +177,21 @@ export const expect = baseExpect.extend({
} }
const message = pass const message = pass
? () => this.utils.matcherHint('toHaveAmount', undefined, undefined, { isNot: this.isNot }) + ? () => this.utils.matcherHint(assertionName, undefined, undefined, { isNot: this.isNot }) +
'\n\n' + '\n\n' +
`Locator: ${locator}\n`, `Locator: ${locator}\n` +
`Expected: ${this.isNot ? 'not' : ''}${this.utils.printExpected(expected)}\n` + `Expected: ${this.isNot ? 'not' : ''}${this.utils.printExpected(expected)}\n` +
(matcherResult ? `Received: ${this.utils.printReceived(matcherResult.actual)}` : '') (matcherResult ? `Received: ${this.utils.printReceived(matcherResult.actual)}` : '')
: () => this.utils.matcherHint('toHaveAmount', undefined, undefined, expectOptions) + : () => this.utils.matcherHint(assertionName, undefined, undefined, { isNot: this.isNot }) +
'\n\n' + '\n\n' +
`Locator: ${locator}\n`, `Locator: ${locator}\n` +
`Expected: ${this.utils.printExpected(expected)}\n` + `Expected: ${this.utils.printExpected(expected)}\n` +
(matcherResult ? `Received: ${this.utils.printReceived(matcherResult.actual)}` : ''); (matcherResult ? `Received: ${this.utils.printReceived(matcherResult.actual)}` : '');
return { return {
message, message,
pass, pass,
name: 'toHaveAmount', name: assertionName,
expected, expected,
actual: matcherResult?.actual, actual: matcherResult?.actual,
}; };