Skip to content

Conversation

@dstaley
Copy link
Member

@dstaley dstaley commented Jun 5, 2025

Description

This PR adds initial support for Vitest in clerk-js.

Right now, clerk-js makes extensive use of Jest for unit tests, and it's not feasible to perform a full replacement in a single PR. So, to support incremental adoption, this PR introduces Vitest support in *.spec.ts files (whereas Jest uses *.test.ts files). This allows us to write tests specifically for Vitest, and move Jest tests to Vitest file by file.

To run both Jest and Vitest tests, you can run pnpm test. Vitest tests can be run in watch mode with pnpm test:vitest.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@vercel
Copy link

vercel bot commented Jun 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 9, 2025 3:53pm

@changeset-bot
Copy link

changeset-bot bot commented Jun 5, 2025

🦋 Changeset detected

Latest commit: 62b1e89

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 5, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6069

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6069

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6069

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6069

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6069

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6069

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6069

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6069

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6069

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6069

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6069

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6069

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6069

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6069

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6069

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6069

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6069

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6069

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6069

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6069

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6069

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6069

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6069

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6069

commit: 62b1e89

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds initial support for Vitest alongside existing Jest tests in the clerk-js package to enable incremental migration.

  • Introduces Vitest setup and configuration files.
  • Migrates select test files (*.spec.ts/.tsx) to Vitest, updating imports and mocks.
  • Updates package scripts and dependencies to include Vitest commands and plugins.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/clerk-js/vitest.setup.mts Global cleanup after each Vitest test
packages/clerk-js/vitest.config.mts Vitest configuration with React plugin and include patterns
packages/clerk-js/src/utils/tests/email.spec.ts Switched email utility tests to Vitest imports
packages/clerk-js/src/ui/router/tests/HashRouter.spec.tsx Migrated router tests from Jest to Vitest (vi.fn, vi.mock)
packages/clerk-js/package.json Updated test script to run Jest and Vitest; added test:vitest
package.json Added @vitejs/plugin-react dependency
.changeset/every-cows-think.md Added empty changeset placeholder
Comments suppressed due to low confidence (1)

.changeset/every-cows-think.md:1

  • This changeset file is empty. Please add a summary and version bump (major/minor/patch) in the frontmatter so releases are correctly generated.
---

Copy link
Member

@jacekradko jacekradko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@dstaley dstaley enabled auto-merge (squash) June 9, 2025 15:52
@dstaley dstaley merged commit 685ddae into main Jun 9, 2025
36 checks passed
@dstaley dstaley deleted the ds.test/clerk-js-vitest branch June 9, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants