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