mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: make web-first matchers work outside of pw tests (#9624)
This commit is contained in:
parent
a346af4ebf
commit
9d03a85c30
@ -27,9 +27,6 @@ export async function toBeTruthy(
|
||||
query: (isNot: boolean, timeout: number) => Promise<{ matches: boolean, log?: string[] }>,
|
||||
options: { timeout?: number } = {},
|
||||
) {
|
||||
const testInfo = currentTestInfo();
|
||||
if (!testInfo)
|
||||
throw new Error(`${matcherName} must be called during the test`);
|
||||
expectType(receiver, receiverType, matcherName);
|
||||
|
||||
const matcherOptions = {
|
||||
@ -37,7 +34,8 @@ export async function toBeTruthy(
|
||||
promise: this.promise,
|
||||
};
|
||||
|
||||
let defaultExpectTimeout = testInfo.project.expect?.timeout;
|
||||
const testInfo = currentTestInfo();
|
||||
let defaultExpectTimeout = testInfo?.project.expect?.timeout;
|
||||
if (typeof defaultExpectTimeout === 'undefined')
|
||||
defaultExpectTimeout = 5000;
|
||||
const timeout = options.timeout === 0 ? 0 : options.timeout || defaultExpectTimeout;
|
||||
|
||||
@ -35,9 +35,6 @@ export async function toEqual<T>(
|
||||
expected: T,
|
||||
options: { timeout?: number, contains?: boolean } = {},
|
||||
) {
|
||||
const testInfo = currentTestInfo();
|
||||
if (!testInfo)
|
||||
throw new Error(`${matcherName} must be called during the test`);
|
||||
expectType(receiver, receiverType, matcherName);
|
||||
|
||||
const matcherOptions = {
|
||||
@ -46,7 +43,8 @@ export async function toEqual<T>(
|
||||
promise: this.promise,
|
||||
};
|
||||
|
||||
let defaultExpectTimeout = testInfo.project.expect?.timeout;
|
||||
const testInfo = currentTestInfo();
|
||||
let defaultExpectTimeout = testInfo?.project.expect?.timeout;
|
||||
if (typeof defaultExpectTimeout === 'undefined')
|
||||
defaultExpectTimeout = 5000;
|
||||
const timeout = options.timeout === 0 ? 0 : options.timeout || defaultExpectTimeout;
|
||||
|
||||
@ -35,9 +35,6 @@ export async function toMatchText(
|
||||
expected: string | RegExp,
|
||||
options: { timeout?: number, matchSubstring?: boolean } = {},
|
||||
) {
|
||||
const testInfo = currentTestInfo();
|
||||
if (!testInfo)
|
||||
throw new Error(`${matcherName} must be called during the test`);
|
||||
expectType(receiver, receiverType, matcherName);
|
||||
|
||||
const matcherOptions = {
|
||||
@ -60,7 +57,8 @@ export async function toMatchText(
|
||||
);
|
||||
}
|
||||
|
||||
let defaultExpectTimeout = testInfo.project.expect?.timeout;
|
||||
const testInfo = currentTestInfo();
|
||||
let defaultExpectTimeout = testInfo?.project.expect?.timeout;
|
||||
if (typeof defaultExpectTimeout === 'undefined')
|
||||
defaultExpectTimeout = 5000;
|
||||
const timeout = options.timeout === 0 ? 0 : options.timeout || defaultExpectTimeout;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user