diff --git a/.changeset/cool-keys-scream.md b/.changeset/cool-keys-scream.md new file mode 100644 index 00000000000..d736cd88437 --- /dev/null +++ b/.changeset/cool-keys-scream.md @@ -0,0 +1,5 @@ +--- +'@clerk/testing': patch +--- + +Fix Playwright route URL to use RegExp instead of Glob URL pattern diff --git a/packages/testing/src/playwright/setupClerkTestingToken.ts b/packages/testing/src/playwright/setupClerkTestingToken.ts index 5b25bb6b06d..5248357f4f6 100644 --- a/packages/testing/src/playwright/setupClerkTestingToken.ts +++ b/packages/testing/src/playwright/setupClerkTestingToken.ts @@ -38,7 +38,9 @@ export const setupClerkTestingToken = async ({ context, options, page }: SetupCl if (!fapiUrl) { throw new Error(ERROR_MISSING_FRONTEND_API_URL); } - const apiUrl = `https://${fapiUrl}/v1/**/*`; + + const escapedFapiUrl = fapiUrl.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const apiUrl = new RegExp(`^https://${escapedFapiUrl}/v1/.*?(\\?.*)?$`); await browserContext.route(apiUrl, async route => { const originalUrl = new URL(route.request().url());