Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e63302f
chore(repo): Update testing to v4
renovate[bot] May 5, 2026
90b43ba
chore(repo): pnpm dedupe
jacekradko May 3, 2026
7f2427f
fix(backend): use relative imports instead of bare 'src/...' paths
jacekradko May 3, 2026
1d7ee8a
fix(backend): sort imports
jacekradko May 4, 2026
11d3d2c
test(fastify): remove obsolete snapshots
jacekradko May 4, 2026
56fc294
test(testing): reset mock call count between tests for vitest 4
jacekradko May 5, 2026
5764cfe
test(clerk-js): use named functions for vitest 4 constructor mocks
jacekradko May 5, 2026
fa408b6
test(clerk-js): use named function in CaptchaChallenge mock for vitest 4
jacekradko May 5, 2026
752fe4e
test(react): use named function in mockClerkCtor for vitest 4
jacekradko May 5, 2026
e1d2510
test(backend): drop redundant miniflare runtime, keep node + edge-run…
jacekradko May 6, 2026
6821d78
test(chrome-extension): fix vitest 4 mock constructor and call-count …
jacekradko May 6, 2026
50196da
test(clerk-js): use named function in ResizeObserver mock for vitest 4
jacekradko May 6, 2026
5eaf5ea
Merge branch 'main' into renovate/major-testing
jacekradko May 6, 2026
11d62c5
Merge remote-tracking branch 'origin/main' into renovate/major-testing
jacekradko Jun 27, 2026
8d631a7
test(repo): fix vitest 4 typecheck and constructor-mock failures from…
jacekradko Jun 27, 2026
078e2dd
chore(repo): dedupe lockfile after main merge
jacekradko Jun 28, 2026
bbcde27
fix(react): add node types to tsconfig so typedoc resolves process/gl…
jacekradko Jun 28, 2026
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
2 changes: 2 additions & 0 deletions .changeset/backend-drop-miniflare-test-env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@types/react": "catalog:react",
"@types/react-dom": "catalog:react",
"@vitejs/plugin-react": "^4.5.2",
"@vitest/coverage-v8": "3.2.6",
"@vitest/coverage-v8": "4.1.5",
"chalk": "4.1.2",
"citty": "^0.1.6",
"conventional-changelog-conventionalcommits": "^4.6.3",
Expand Down Expand Up @@ -150,7 +150,7 @@
"typescript-eslint": "8.58.0",
"unrun": "0.2.39",
"uuid": "8.3.2",
"vitest": "3.2.6",
"vitest": "4.1.5",
"zx": "catalog:repo"
},
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
Expand Down
9 changes: 3 additions & 6 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16 --ignore-rules false-cjs",
"lint:publint": "publint",
"test": "run-s test:node test:edge-runtime test:cloudflare-miniflare",
"test:cloudflare-miniflare": "vitest run --environment miniflare",
"test": "run-s test:node test:edge-runtime",
"test:edge-runtime": "vitest run --environment edge-runtime",
"test:node": "vitest run --environment node",
"test:watch": "run-s test:watch:node test:watch:edge-runtime test:watch:cloudflare-miniflare",
"test:watch:cloudflare-miniflare": "vitest watch --environment miniflare",
"test:watch": "run-s test:watch:node test:watch:edge-runtime",
"test:watch:edge-runtime": "vitest watch --environment edge-runtime",
"test:watch:node": "vitest watch --environment node"
},
Expand All @@ -128,8 +126,7 @@
"cookie": "1.1.1",
"msw": "2.14.2",
"npm-run-all": "^4.1.5",
"snakecase-keys": "9.0.2",
"vitest-environment-miniflare": "2.14.4"
"snakecase-keys": "9.0.2"
},
"engines": {
"node": ">=20.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('StorageCache', () => {
describe('get', () => {
afterEach(() => {
vi.restoreAllMocks();
vi.mocked(browser.storage.local.get).mockClear();
});

test('value missing', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const mockLoad = vi.fn().mockResolvedValue(undefined);
const mockUi = { __brand: 'clerk-ui', ClerkUI: vi.fn() };

vi.mock('@clerk/clerk-js/no-rhc', () => {
const Clerk = vi.fn(() => ({
load: mockLoad,
})) as ReturnType<typeof vi.fn> & { sdkMetadata: Record<string, string> };
const Clerk = vi.fn(function () {
return { load: mockLoad };
}) as ReturnType<typeof vi.fn> & { sdkMetadata: Record<string, string> };
Clerk.sdkMetadata = {};
return { Clerk };
});
Expand Down
12 changes: 9 additions & 3 deletions packages/clerk-js/src/core/__tests__/clerk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3095,7 +3095,9 @@ describe('Clerk singleton', () => {

it('uses ui.ClerkUI when provided', async () => {
const mockClerkUIInstance = { mount: vi.fn() };
const mockClerkUICtor = vi.fn(() => mockClerkUIInstance);
const mockClerkUICtor = vi.fn(function () {
return mockClerkUIInstance;
});

const sut = new Clerk(productionPublishableKey);
await sut.load({
Expand All @@ -3108,7 +3110,9 @@ describe('Clerk singleton', () => {

it('supports legacy clerkUICtor option for backwards compatibility', async () => {
const mockClerkUIInstance = { mount: vi.fn() };
const mockClerkUICtor = vi.fn(() => mockClerkUIInstance);
const mockClerkUICtor = vi.fn(function () {
return mockClerkUIInstance;
});

const sut = new Clerk(productionPublishableKey);
await sut.load({
Expand All @@ -3121,7 +3125,9 @@ describe('Clerk singleton', () => {

it('supports legacy clerkUiCtor option for backwards compatibility', async () => {
const mockClerkUIInstance = { mount: vi.fn() };
const mockClerkUICtor = vi.fn(() => mockClerkUIInstance);
const mockClerkUICtor = vi.fn(function () {
return mockClerkUIInstance;
});

const sut = new Clerk(productionPublishableKey);
await sut.load({
Expand Down
4 changes: 3 additions & 1 deletion packages/clerk-js/src/core/__tests__/tokenCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ describe('SessionTokenCache', () => {
SessionTokenCache.close();

// Now mock BroadcastChannel so next initialization uses the mock
global.BroadcastChannel = vi.fn(() => mockBroadcastChannel) as any;
global.BroadcastChannel = vi.fn(function () {
return mockBroadcastChannel;
}) as any;

SessionTokenCache.clear();

Expand Down
14 changes: 8 additions & 6 deletions packages/clerk-js/src/core/resources/__tests__/SignIn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import { _futureAuthenticateWithPopup } from '../../../utils/authenticateWithPop

// Mock the CaptchaChallenge module
vi.mock('../../../utils/captcha/CaptchaChallenge', () => ({
CaptchaChallenge: vi.fn().mockImplementation(() => ({
managedOrInvisible: vi.fn().mockResolvedValue({
captchaToken: 'mock_captcha_token',
captchaWidgetType: 'invisible',
}),
})),
CaptchaChallenge: vi.fn().mockImplementation(function () {
return {
managedOrInvisible: vi.fn().mockResolvedValue({
captchaToken: 'mock_captcha_token',
captchaWidgetType: 'invisible',
}),
};
}),
}));

describe('SignIn', () => {
Expand Down
14 changes: 8 additions & 6 deletions packages/clerk-js/src/core/resources/__tests__/SignUp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import { CaptchaChallenge } from '../../../utils/captcha/CaptchaChallenge';

// Mock the CaptchaChallenge module
vi.mock('../../../utils/captcha/CaptchaChallenge', () => ({
CaptchaChallenge: vi.fn().mockImplementation(() => ({
managedOrInvisible: vi.fn().mockResolvedValue({
captchaToken: 'mock_token',
captchaWidgetType: 'invisible',
}),
})),
CaptchaChallenge: vi.fn().mockImplementation(function () {
return {
managedOrInvisible: vi.fn().mockResolvedValue({
captchaToken: 'mock_token',
captchaWidgetType: 'invisible',
}),
};
}),
}));

describe('SignUp', () => {
Expand Down
22 changes: 13 additions & 9 deletions packages/clerk-js/vitest.setup.mts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ if (typeof window !== 'undefined') {
// Mock ResizeObserver
window.ResizeObserver =
window.ResizeObserver ||
vi.fn().mockImplementation(() => ({
disconnect: vi.fn(),
observe: vi.fn(),
unobserve: vi.fn(),
}));
(vi.fn().mockImplementation(function () {
return {
disconnect: vi.fn(),
observe: vi.fn(),
unobserve: vi.fn(),
};
}) as unknown as typeof ResizeObserver);

// Mock matchMedia
Object.defineProperty(window, 'matchMedia', {
Expand Down Expand Up @@ -300,10 +302,12 @@ vi.mock('@formkit/auto-animate', () => ({
// Mock browser-tabs-lock to prevent window access errors in tests
vi.mock('browser-tabs-lock', () => {
return {
default: vi.fn().mockImplementation(() => ({
acquireLock: vi.fn().mockResolvedValue(true),
releaseLock: vi.fn().mockResolvedValue(true),
})),
default: vi.fn().mockImplementation(function () {
return {
acquireLock: vi.fn().mockResolvedValue(true),
releaseLock: vi.fn().mockResolvedValue(true),
};
}),
};
});

Expand Down
12 changes: 7 additions & 5 deletions packages/electron/src/storage/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ vi.mock('electron', () => ({
}));

vi.mock('electron-store', () => ({
default: vi.fn(() => ({
get: storeGet,
set: storeSet,
delete: storeDelete,
})),
default: vi.fn(function () {
return {
get: storeGet,
set: storeSet,
delete: storeDelete,
};
}),
}));

const ss = safeStorage as unknown as Record<string, unknown>;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,3 @@ exports[`constants > from environment variables 1`] = `
"SECRET_KEY": "TEST_SECRET_KEY",
}
`;

exports[`constants from environment variables 1`] = `
{
"API_URL": "CLERK_API_URL",
"API_VERSION": "CLERK_API_VERSION",
"JWT_KEY": "CLERK_JWT_KEY",
"PUBLISHABLE_KEY": "CLERK_PUBLISHABLE_KEY",
"SDK_METADATA": {
"environment": "test",
"name": "@clerk/fastify",
"version": "0.0.0-test",
},
"SECRET_KEY": "CLERK_SECRET_KEY",
}
`;
14 changes: 0 additions & 14 deletions packages/fastify/src/__tests__/__snapshots__/getAuth.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,3 @@ For more info, check out the docs: https://clerk.com/docs,
or come say hi in our discord server: https://clerk.com/discord
]
`;

exports[`getAuth(req) throws error if clerkPlugin is on registered 1`] = `
"🔒 Clerk: The "clerkPlugin" should be registered before using the "getAuth".
Example:

import { clerkPlugin } from '@clerk/fastify';

const server: FastifyInstance = Fastify({ logger: true });
server.register(clerkPlugin);

For more info, check out the docs: https://clerk.com/docs,
or come say hi in our discord server: https://clerk.com/discord
"
`;
10 changes: 6 additions & 4 deletions packages/react/src/__tests__/isomorphicClerk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
SignInResource,
UnsubscribeCallback,
} from '@clerk/shared/types';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, type Mock, vi } from 'vitest';

import { IsomorphicClerk } from '../isomorphicClerk';

Expand Down Expand Up @@ -215,7 +215,9 @@ describe('isomorphicClerk', () => {
load: vi.fn().mockResolvedValue(undefined),
loaded: false,
};
const mockClerkCtor = vi.fn().mockImplementation(() => mockInstance);
const mockClerkCtor = vi.fn().mockImplementation(function () {
return mockInstance;
});
mockClerkCtor.prototype = {};

const clerk = new IsomorphicClerk({
Expand Down Expand Up @@ -437,12 +439,12 @@ describe('isomorphicClerk', () => {

describe('__internal_windowNavigate', () => {
let originalLocation: Location;
let hrefSetter: ReturnType<typeof vi.fn>;
let hrefSetter: Mock<(value: unknown) => void>;
let warnSpy: ReturnType<typeof vi.spyOn>;

beforeEach(() => {
originalLocation = window.location;
hrefSetter = vi.fn();
hrefSetter = vi.fn<(value: unknown) => void>();
Object.defineProperty(window, 'location', {
configurable: true,
value: new Proxy(
Expand Down
3 changes: 2 additions & 1 deletion packages/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"importHelpers": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es6", "dom"],
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"moduleResolution": "Bundler",
"module": "preserve",
"noImplicitReturns": true,
Expand All @@ -16,6 +16,7 @@
"sourceMap": false,
"strict": true,
"target": "ES2019",
"types": ["node"],
"rootDir": "./src"
},
"include": ["src"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { afterEach, beforeEach, describe, expect, it, type Mock, vi } from 'vitest';

import { ALLOWED_PROTOCOLS, CLERK_BEFORE_UNLOAD_EVENT, windowNavigate } from '../windowNavigate';

describe('windowNavigate', () => {
let originalLocation: Location;
let hrefSetter: ReturnType<typeof vi.fn>;
let hrefSetter: Mock<(value: unknown) => void>;
let warnSpy: ReturnType<typeof vi.spyOn>;
let eventSpy: ReturnType<typeof vi.fn>;
let eventSpy: Mock<(event: Event) => void>;

beforeEach(() => {
originalLocation = window.location;
hrefSetter = vi.fn();
hrefSetter = vi.fn<(value: unknown) => void>();
Object.defineProperty(window, 'location', {
configurable: true,
value: new Proxy(
Expand All @@ -29,7 +29,7 @@ describe('windowNavigate', () => {
),
});
warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
eventSpy = vi.fn();
eventSpy = vi.fn<(event: Event) => void>();
window.addEventListener(CLERK_BEFORE_UNLOAD_EVENT, eventSpy);
});

Expand Down
1 change: 1 addition & 0 deletions packages/testing/src/common/__tests__/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('fetchWithRetry (via fetchEnvVars)', () => {
const mockCreateTestingToken = vi.fn();

beforeEach(() => {
mockCreateTestingToken.mockReset();
vi.useFakeTimers();
vi.stubEnv('CLERK_PUBLISHABLE_KEY', 'pk_test_abc');
vi.stubEnv('CLERK_SECRET_KEY', 'sk_test_abc');
Expand Down
Loading
Loading