diff --git a/packages/playwright/src/matchers/toEqual.ts b/packages/playwright/src/matchers/toEqual.ts index e19652829d..4296444a7b 100644 --- a/packages/playwright/src/matchers/toEqual.ts +++ b/packages/playwright/src/matchers/toEqual.ts @@ -19,6 +19,7 @@ import { matcherHint } from './matcherHint'; import type { MatcherResult } from './matcherHint'; import type { ExpectMatcherState } from '../../types/test'; import type { Locator } from 'playwright-core'; +import { isRegExp } from 'playwright-core/lib/utils'; // Omit colon and one or more spaces, so can call getLabelPrinter. const EXPECTED_LABEL = 'Expected'; @@ -62,7 +63,7 @@ export async function toEqual( } else if (Array.isArray(expected) && Array.isArray(received)) { const normalizedExpected = expected.map((exp, index) => { const rec = received[index]; - if (exp instanceof RegExp) + if (isRegExp(exp)) return exp.test(rec) ? rec : exp; return exp;