Docs

Testing

Testing is an important part of every application. Clerk has built some helpers to make testing your application with Clerk easier, with more on the way. Each framework may require a slightly different setup. If you're having trouble getting testing to work properly, send us a message and we'll be able to help.

Testing with one time passcodes

To avoid sending an email or SMS message with a one time passcode (OTP) during testing, you can use a faux email address or phone number that has a fixed code. Read the complete documentation here.

Testing Tokens

Testing Tokens enable bypassing various bot detection mechanisms that typically safeguard Clerk applications against malicious bots, thus allowing test suites to run uninhibited. Without Testing Tokens, you may encounter "Bot traffic detected" errors in your requests.

Note

While manually implementing the following logic in your test suite is possible, Clerk offers a Playwright integration which will automatically take care of all of this.

Obtained via the Backend API, Testing Tokens are short-lived and valid only for the specific instance for which they are issued. Testing Tokens are only available in development instances.

Upon retrieval, include the token value in a __clerk_testing_token query parameter with your Frontend API requests. For instance, a sign-up request using a Testing Token would look like this:

POST https://happy-hippo-1.clerk.accounts.dev/v1/sign_ups?__clerk_testing_token=1713877200-c_2J2MvPu9PnXcuhbPZNao0LOXqK9A7YrnBn0HmIWxy

For more information, feedback or issues, visit the @clerk/testing package.

Feedback

What did you think of this content?