This package provides utilities for testing Clerk applications.
It currently supports the following testing frameworks:
Playwright, a Node.js library to automate browsers and web pages.
Cypress, a JavaScript-based end-to-end testing framework.
Getting started
Prerequisites
Node.js >=18.17.0 or later
Playwright v1+ or Cypress v13+
Installation
npm install @clerk/testing --save-dev
Usage
Playwright
Firstly, add your Clerk keys (CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY) to your environment variables file (e.g. .env.local or .env.).
You can find these keys in your Clerk Dashboard.
All Playwright related utilities are exported from @clerk/testing/playwright. Make sure that your import paths are correct!
In your global setup file for Playwright, you must use the clerkSetup function to set up Clerk for your tests.
⚠️ Please note: Support for Cypress is still experimental. Be aware that there are limitations and potential issues at this stage. Please open an issue with a minimal reproduction so that these issues can be fixed. Thanks!
Firstly, add your Clerk keys (CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY) to your environment variables file (e.g. .env.local or .env.).
You can find these keys in your Clerk Dashboard.
All Cypress related utilities are exported from @clerk/testing/cypress. Make sure that your import paths are correct!
In your cypress.config.ts, you must use the clerkSetup function to set up Clerk for your tests.
Keep in mind that you must pass the Cypress config object to the clerkSetup function and also return the new config object from the setupNodeEvents function.
Utilities to help you create E2E test suites for apps using Clerk
The npm package @clerk/testing receives a total of 14,788 weekly downloads. As such, @clerk/testing popularity was classified as popular.
We found that @clerk/testing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 8 open source maintainers collaborating on the project.
Package last updated on 10 Jul 2024
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
By Kirill Boychenko, Peter van der Zee - Jan 29, 2025
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.