Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-beds-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/testing': patch
---

Improve the error message when `setupClerkTestingToken` cannot find the FAPI URL
3 changes: 3 additions & 0 deletions packages/testing/src/common/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const ERROR_MISSING_FRONTEND_API_URL =
'The Clerk Frontend API URL is required to bypass bot protection. ' +
'Make sure the clerkSetup function is called during your global setup before setupClerkTestingToken is called.';
1 change: 1 addition & 0 deletions packages/testing/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './constants';
export * from './types';
export * from './setup';
export * from './errors';
4 changes: 2 additions & 2 deletions packages/testing/src/cypress/setupClerkTestingToken.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />
import type { SetupClerkTestingTokenOptions } from '../common';
import { TESTING_TOKEN_PARAM } from '../common';
import { ERROR_MISSING_FRONTEND_API_URL, TESTING_TOKEN_PARAM } from '../common';

type SetupClerkTestingTokenParams = {
options?: SetupClerkTestingTokenOptions;
Expand All @@ -24,7 +24,7 @@ type SetupClerkTestingTokenParams = {
export const setupClerkTestingToken = (params?: SetupClerkTestingTokenParams) => {
const fapiUrl = params?.options?.frontendApiUrl || Cypress.env('CLERK_FAPI');
if (!fapiUrl) {
throw new Error('The Frontend API URL is required to bypass bot protection.');
throw new Error(ERROR_MISSING_FRONTEND_API_URL);
}
const apiUrl = `https://${fapiUrl}/v1/**`;

Expand Down
4 changes: 2 additions & 2 deletions packages/testing/src/playwright/setupClerkTestingToken.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Page } from '@playwright/test';

import type { SetupClerkTestingTokenOptions } from '../common';
import { TESTING_TOKEN_PARAM } from '../common';
import { ERROR_MISSING_FRONTEND_API_URL, TESTING_TOKEN_PARAM } from '../common';

type SetupClerkTestingTokenParams = {
page: Page;
Expand All @@ -27,7 +27,7 @@ type SetupClerkTestingTokenParams = {
export const setupClerkTestingToken = async ({ page, options }: SetupClerkTestingTokenParams) => {
const fapiUrl = options?.frontendApiUrl || process.env.CLERK_FAPI;
if (!fapiUrl) {
throw new Error('The Frontend API URL is required to bypass bot protection.');
throw new Error(ERROR_MISSING_FRONTEND_API_URL);
}
const apiUrl = `https://${fapiUrl}/v1/**/*`;

Expand Down