chore: replace regex check with isRegExp from playwright-core/lib/utils
This commit is contained in:
parent
bc85868e63
commit
4141467ee5
|
|
@ -19,6 +19,7 @@ import { matcherHint } from './matcherHint';
|
||||||
import type { MatcherResult } from './matcherHint';
|
import type { MatcherResult } from './matcherHint';
|
||||||
import type { ExpectMatcherState } from '../../types/test';
|
import type { ExpectMatcherState } from '../../types/test';
|
||||||
import type { Locator } from 'playwright-core';
|
import type { Locator } from 'playwright-core';
|
||||||
|
import { isRegExp } from 'playwright-core/lib/utils';
|
||||||
|
|
||||||
// Omit colon and one or more spaces, so can call getLabelPrinter.
|
// Omit colon and one or more spaces, so can call getLabelPrinter.
|
||||||
const EXPECTED_LABEL = 'Expected';
|
const EXPECTED_LABEL = 'Expected';
|
||||||
|
|
@ -62,7 +63,7 @@ export async function toEqual<T>(
|
||||||
} else if (Array.isArray(expected) && Array.isArray(received)) {
|
} else if (Array.isArray(expected) && Array.isArray(received)) {
|
||||||
const normalizedExpected = expected.map((exp, index) => {
|
const normalizedExpected = expected.map((exp, index) => {
|
||||||
const rec = received[index];
|
const rec = received[index];
|
||||||
if (exp instanceof RegExp)
|
if (isRegExp(exp))
|
||||||
return exp.test(rec) ? rec : exp;
|
return exp.test(rec) ? rec : exp;
|
||||||
|
|
||||||
return exp;
|
return exp;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue