-
Notifications
You must be signed in to change notification settings - Fork 388
chore(chrome-extension): Replace Jest with Vitest #6820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 1203c64 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen 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 |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughReplaces Jest with Vitest for the chrome-extension package (scripts, config, setup, and tests); adds a placeholder changeset; updates root Vitest-related devDependencies; removes chrome-extension Jest config file; adjusts Next.js TypeScript lib and removes a TS expect-error comment; updates .gitignore. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant CLI as Vitest CLI
participant Cfg as vitest.config.mts
participant Setup as vitest.setup.mts
participant JC as jest-chrome
participant Tests as Test Suites
Dev->>CLI: run `vitest` / `vitest run`
CLI->>Cfg: load config (env, jsdom, globals PACKAGE_NAME/PACKAGE_VERSION)
CLI->>Setup: execute setup file
note right of Setup #e8f6ff: assign globalThis.jest = vi\nthen import `jest-chrome`
Setup->>JC: initialize chrome mocks
CLI->>Tests: discover & run `**/*.test.{ts,tsx}`
Tests->>JC: use chrome.* mocks via global `jest`
Tests-->>CLI: return results
CLI-->>Dev: report pass/fail
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
⛔ Files ignored due to path filters (2)
📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
Comment |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts (1)
44-44
: Replace jest.fn with vi.fnpackages/chrome-extension/src/internal/utils/tests/cookies.test.ts:44
- expect(await getClientCookie({ callback: jest.fn(), name, url })).toBe(cookie); + expect(await getClientCookie({ callback: vi.fn(), name, url })).toBe(cookie);
🧹 Nitpick comments (7)
.changeset/brown-icons-shine.md (1)
1-2
: Optional: add a note so this empty changeset is self‑documenting.Empty changesets are fine; adding a one‑line body helps future readers.
Apply this diff:
--- --- +chore(chrome-extension): migrate tests from Jest to Vitest (no published changes)
If your pipeline discourages empty changesets, confirm this is intentional for a non-publishing infra change.
packages/chrome-extension/vitest.setup.mts (1)
9-9
: Prefer globalThis over global for portability.Minor consistency tweak with the earlier globalThis usage.
Apply this diff:
-Object.assign(global, { chrome, browser: chrome }); +Object.assign(globalThis, { chrome, browser: chrome });packages/chrome-extension/package.json (1)
47-48
: Scripts migration to Vitest looks good.If CI depends on coverage, consider adding a coverage script with v8 provider; otherwise ignore.
Optional:
"scripts": { ... - "test": "vitest", - "test:ci": "vitest run --maxWorkers=70%" + "test": "vitest", + "test:ci": "vitest run --maxWorkers=70%", + "test:coverage": "vitest run --coverage" },Confirm that removing the old
test:coverage
doesn’t affect any CI jobs expecting it.packages/chrome-extension/vitest.config.mts (4)
8-11
: Declare types for PACKAGE_NAME / PACKAGE_VERSION.These are injected at build time; TS will flag usage unless declared in a .d.ts included by tsconfig.test.json.
Add a file (e.g., packages/chrome-extension/env.globals.d.ts):
declare const PACKAGE_NAME: string; declare const PACKAGE_VERSION: string;Ensure tsconfig.test.json includes it.
13-17
: Typecheck also .spec. files.*Current include only matches .test.. Many repos also use .spec..
- include: ['**/*.test.{ts,tsx}'], + include: ['**/*.{test,spec}.{ts,tsx}'],
22-22
: Scope includeSource to sources to speed up collection.The global pattern can pull in config/setup and other non‑source files.
- includeSource: ['**/*.{js,ts,jsx,tsx}'], + includeSource: ['src/**/*.{js,ts,jsx,tsx}'],Adjust the glob if your sources live outside src/.
7-7
: Remove empty plugins array.No plugins configured—drop the empty property.
- plugins: [],
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (2)
packages/chrome-extension/src/__tests__/__snapshots__/exports.test.ts.snap
is excluded by!**/*.snap
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (10)
.changeset/brown-icons-shine.md
(1 hunks)package.json
(1 hunks)packages/chrome-extension/jest.config.js
(0 hunks)packages/chrome-extension/package.json
(1 hunks)packages/chrome-extension/src/__tests__/exports.test.ts
(1 hunks)packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
(2 hunks)packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
(1 hunks)packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
(4 hunks)packages/chrome-extension/vitest.config.mts
(1 hunks)packages/chrome-extension/vitest.setup.mts
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/chrome-extension/jest.config.js
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
package.json
packages/chrome-extension/src/__tests__/exports.test.ts
packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
packages/chrome-extension/package.json
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/chrome-extension/src/__tests__/exports.test.ts
packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/chrome-extension/src/__tests__/exports.test.ts
packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/chrome-extension/src/__tests__/exports.test.ts
packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/chrome-extension/src/__tests__/exports.test.ts
packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/chrome-extension/src/__tests__/exports.test.ts
packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/chrome-extension/src/__tests__/exports.test.ts
packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/chrome-extension/src/__tests__/exports.test.ts
packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
packages/*/package.json
📄 CodeRabbit inference engine (.cursor/rules/global.mdc)
All publishable packages should be placed under the packages/ directory
packages/*/package.json
: All publishable packages must be located in the 'packages/' directory.
All packages must be published under the @clerk namespace on npm.
Semantic versioning must be used across all packages.
Files:
packages/chrome-extension/package.json
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/brown-icons-shine.md
🧬 Code graph analysis (1)
packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts (1)
packages/chrome-extension/src/internal/utils/storage.ts (1)
BrowserStorageCache
(46-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (6)
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts (1)
28-32
: Good swap to vi.mocked and proper reset/restore.packages/chrome-extension/src/internal/utils/__tests__/manifest.test.ts (1)
1-1
: LGTM: explicit Vitest imports.packages/chrome-extension/vitest.setup.mts (1)
1-4
: LGTM: aliasing jest to vi before importing jest‑chrome is correct.packages/chrome-extension/src/__tests__/exports.test.ts (1)
1-1
: LGTM: moved to Vitest APIs; snapshot test remains stable.packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts (1)
25-30
: Nice Vitest migration + stronger assertions.
- Using vi.mocked with argument verification tightens the contract.
- afterEach with vi.restoreAllMocks prevents cross‑test bleed.
Also applies to: 35-40, 44-47, 49-54, 57-62
packages/chrome-extension/vitest.config.mts (1)
1-25
: Sanity check — vitest config & package globals verified.
All referenced files exist (packages/chrome-extension/{vitest.config.mts, tsconfig.test.json, vitest.setup.mts, package.json}); vitest defines PACKAGE_NAME/PACKAGE_VERSION and matching declarations exist at packages/chrome-extension/src/global.d.ts; usages found in packages/chrome-extension/tsup.config.ts, packages/chrome-extension/src/internal/clerk.ts, and packages/chrome-extension/src/index.ts; config path refs confirmed.
import { defineConfig } from 'vitest/config'; | ||
import { readFileSync } from 'node:fs'; | ||
|
||
const { name, version } = JSON.parse(readFileSync('./package.json', 'utf8')); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make config CWD‑independent (monorepo‑safe).
Relative paths here resolve from process.cwd(), which can point to the repo root when running Vitest via a workspace filter. Read package.json and resolve tsconfig/setupFiles relative to this config file to avoid misreads/breakage.
Apply this diff:
@@
-import { defineConfig } from 'vitest/config';
-import { readFileSync } from 'node:fs';
+import { defineConfig } from 'vitest/config';
+import { readFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { resolve } from 'node:path';
@@
-const { name, version } = JSON.parse(readFileSync('./package.json', 'utf8'));
+const rootDir = fileURLToPath(new URL('.', import.meta.url));
+const { name, version } = JSON.parse(
+ readFileSync(new URL('./package.json', import.meta.url), 'utf8'),
+);
@@
-export default defineConfig({
- plugins: [],
+export default defineConfig({
+ root: rootDir,
+ plugins: [],
@@
- tsconfig: './tsconfig.test.json',
+ tsconfig: resolve(rootDir, 'tsconfig.test.json'),
@@
- setupFiles: './vitest.setup.mts',
+ setupFiles: resolve(rootDir, 'vitest.setup.mts'),
Also applies to: 6-9, 15-16, 23-23
🤖 Prompt for AI Agents
In packages/chrome-extension/vitest.config.mts around lines 1-5 (and similarly
for lines 6-9, 15-16, 23-23), relative paths are being resolved from
process.cwd(), which breaks in a monorepo; change file-loading and path
resolution to be relative to this config file by using import.meta.url (e.g.
read package.json via new URL('./package.json', import.meta.url) and resolve
tsconfig/setupFiles using new URL('./path/to/file', import.meta.url) or URL +
pathname, then pass the resulting absolute paths to Vitest so the config is
CWD‑independent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts (1)
28-33
: Use vi.spyOn instead of vi.mocked; mockRestore only works on spies
vi.mocked
is a type helper; it doesn’t turnbrowser.cookies.get
into a spy. CallingmockRestore
on a non‑spy will fail. Spy on the method, then reset/restore the spy.Apply this diff:
- // eslint-disable-next-line jest/unbound-method -- The Jest ESLint plugin doesn't support Vitest - const getMock = vi.mocked(browser.cookies.get); + const getSpy = vi.spyOn(browser.cookies, 'get'); - afterEach(() => getMock.mockReset()); - afterAll(() => getMock.mockRestore()); + afterEach(() => getSpy.mockReset()); + afterAll(() => getSpy.mockRestore());And update usages below:
- function expectMockCalls(mockedFn: typeof getMock, name: string, urls: string[]) { + function expectMockCalls(mockedFn: typeof getSpy, name: string, urls: string[]) { - expect(mockedFn.mock.calls.flat()).toEqual(urls.map(url => ({ url, name }))); + expect(mockedFn.mock.calls.map(([arg]) => arg)).toEqual(urls.map(url => ({ url, name }))); }
🧹 Nitpick comments (2)
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts (2)
43-48
: Align with Vitest API and updated spy nameUse the spy instance and prefer
vi.fn()
for consistency with the migration.Apply this diff:
- getMock.mockResolvedValue(cookie); + getSpy.mockResolvedValue(cookie); - expect(await getClientCookie({ callback: jest.fn(), name, url })).toBe(cookie); + expect(await getClientCookie({ callback: vi.fn(), name, url })).toBe(cookie); - expectMockCalls(getMock, name, [url]); + expectMockCalls(getSpy, name, [url]);
40-41
: Test description vs. assertion mismatch (value vs. object)Name says “cookie value” but the assertion checks the whole cookie object identity. Either rename the test or assert on
cookie.value
.Option A (rename):
- test('returns cookie value from browser.cookies if is set for url', async () => { + test('returns cookie from browser.cookies if it is set for the url', async () => {Option B (assert value):
- expect(await getClientCookie({ callback: vi.fn(), name, url })).toBe(cookie); + expect((await getClientCookie({ callback: vi.fn(), name, url }))?.value).toBe(cookie.value);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
(2 hunks)packages/chrome-extension/src/internal/utils/__tests__/storage.test.ts
(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/chrome-extension/src/internal/utils/tests/storage.test.ts
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (28)
- GitHub Check: Integration Tests (tanstack-react-router, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 14)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (machine, chrome)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (elements, chrome)
- GitHub Check: Integration Tests (expo-web, chrome)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (quickstart, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Unit Tests (22, **)
- GitHub Check: Publish with pkg-pr-new
- GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
- GitHub Check: Static analysis
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/chrome-extension/src/internal/utils/__tests__/cookies.test.ts (1)
1-1
: Vitest import migration looks correctDirect Vitest imports are fine here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/nextjs/src/server/clerkMiddleware.ts
(0 hunks)packages/nextjs/tsconfig.json
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/nextjs/src/server/clerkMiddleware.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/nextjs/tsconfig.json
packages/*/tsconfig.json
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Type checking must be performed with TypeScript and publint.
Files:
packages/nextjs/tsconfig.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/nextjs/tsconfig.json (1)
1-24
: Confirm intent: Next.js tsconfig change in a chrome-extension Vitest PR.This tweak lives in packages/nextjs and seems orthogonal to the chrome-extension Jest→Vitest migration. Confirm it’s intentional and won’t be bundled with unrelated changes.
"isolatedModules": true, | ||
"jsx": "react", | ||
"lib": ["es6", "dom"], | ||
"lib": ["es6", "dom", "dom.iterable"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix lib/target mismatch: use ES2019 libs (or drop custom lib).
Specifying "lib": ["es6", ...] while "target" is "ES2019" removes ES2016–ES2019 lib typings (Promise.finally, newer Array/TypedArray methods, etc.). Use ES2019 to match target (plus DOM libs) or omit "lib" entirely and rely on defaults if DOM isn’t required everywhere.
- "lib": ["es6", "dom", "dom.iterable"],
+ "lib": ["es2019", "dom", "dom.iterable"],
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"lib": ["es6", "dom", "dom.iterable"], | |
"lib": ["es2019", "dom", "dom.iterable"], |
🤖 Prompt for AI Agents
In packages/nextjs/tsconfig.json around line 9, the "lib" entry uses "es6" which
conflicts with the "target": "ES2019" setting and omits ES2016–ES2019 type
definitions; update the "lib" to include "ES2019" (and DOM/dom.iterable if
needed) or remove the custom "lib" entirely so TypeScript defaults match the
target, ensuring typings like Promise.finally and newer array/typedarray methods
are available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/chrome-extension/package.json (1)
47-49
: Optional: add a coverage script for parityIf coverage is package-scoped (vs. only at root), consider adding:
"scripts": { "build": "tsup", "postbuild": "node ../../scripts/search-for-rhc.mjs directory dist", @@ - "test:watch": "vitest" + "test:watch": "vitest", + "test:coverage": "vitest run --coverage" },
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
package.json
(2 hunks)packages/chrome-extension/package.json
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/chrome-extension/package.json
packages/*/package.json
📄 CodeRabbit inference engine (.cursor/rules/global.mdc)
All publishable packages should be placed under the packages/ directory
packages/*/package.json
: All publishable packages must be located in the 'packages/' directory.
All packages must be published under the @clerk namespace on npm.
Semantic versioning must be used across all packages.
Files:
packages/chrome-extension/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
"test": "vitest run", | ||
"test:ci": "vitest run --maxWorkers=70%", | ||
"test:watch": "vitest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Vitest switch LGTM; please verify flag support and workspace bin resolution
- Confirm the repo’s Vitest version supports
--maxWorkers=70%
. - Ensure this package can resolve the
vitest
binary (since it’s not listed in this package’s devDependencies).
🏁 Script executed:
#!/bin/bash
# 1) Check Vitest version at repo root
jq -r '.devDependencies.vitest // .dependencies.vitest // .pnpm.overrides.vitest // empty' package.json
# 2) Verify this package does not declare vitest (expected if using root toolchain)
jq -r '.devDependencies.vitest // empty' packages/chrome-extension/package.json
# 3) (Optional) Inspect root scripts to see how tests are invoked in CI
jq -r '.scripts | to_entries[] | select(.key|test("test|ci|vitest|coverage")) | "\(.key): \(.value)"' package.json
Length of output: 2613
🌐 Web query:
Does Vitest support the CLI flag `--maxWorkers` with percentage values (e.g., `--maxWorkers=70%`)? If yes, since which version?
💡 Result:
Yes. Vitest's maxWorkers accepts numeric or percentage values (e.g. --maxWorkers=70%). It was added in the v1.1.0 release (Dec 19, 2023), and a parsing fix for --maxWorkers/--minWorkers was applied in Jan 2024 (PR #7759). [1][2][3]
Sources:
- v1.1.0 release notes (adds --maxWorkers/--minWorkers). [1]
- Vitest CLI/config docs stating "Maximum number or percentage of workers" for maxWorkers. [2]
- PR fixing parsing of --maxWorkers/--minWorkers (Jan 10, 2024). [3]
Add Vitest devDependency and confirm flag support
Verified v3.2.4 (≥v1.1.0) accepts --maxWorkers=70%
. Add "vitest": "^3.2.4"
to packages/chrome-extension/package.json devDependencies so its vitest
scripts resolve the CLI binary.
🤖 Prompt for AI Agents
In packages/chrome-extension/package.json around lines 47 to 49, add a
devDependency entry "vitest": "^3.2.4" to ensure the package-local vitest CLI is
used for the existing "test", "test:ci", and "test:watch" scripts and that the
--maxWorkers flag is supported; update devDependencies to include that version,
run package manager install to update lockfile, and commit the package.json and
lockfile changes.
Description
This PR replaces Jest with Vitest for
@clerk/chrome-extension
. In order to get--maxWorkers=70%
to work correctly, it also updatesvitest
to the latest version. This in turn caused a previous@ts-expect-error
directive to become unused (for some reason??). Addingdom.iterable
to thelib
config for@clerk/nextjs
fixed the type error, allowing for the removal of the directive.Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit