From 4141467ee5fbf612518a41b3a240999e56f22673 Mon Sep 17 00:00:00 2001 From: Pengoose Date: Tue, 12 Nov 2024 09:12:04 +0900 Subject: [PATCH] chore: replace regex check with isRegExp from playwright-core/lib/utils --- packages/playwright/src/matchers/toEqual.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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;