Skip to content

Commit 9a82b66

Browse files
committed
wip
1 parent 7c35866 commit 9a82b66

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

packages/clerk-js/src/testUtils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// eslint-disable-next-line no-restricted-imports
22
import { matchers } from '@emotion/jest';
3+
import { jest } from '@jest/globals';
34
import type { RenderOptions } from '@testing-library/react';
45
import { render as _render } from '@testing-library/react';
56
import UserEvent from '@testing-library/user-event';
6-
import { afterAll, beforeAll, describe, expect, vi, type SpyInstance } from 'vitest';
7+
import type { SpyInstance } from 'jest-mock';
78

89
expect.extend(matchers);
910

10-
Element.prototype.scrollIntoView = vi.fn();
11+
Element.prototype.scrollIntoView = jest.fn();
1112

1213
const render = (ui: React.ReactElement, options?: RenderOptions) => {
1314
const userEvent = UserEvent.setup({ delay: null });
@@ -35,10 +36,10 @@ export const mockNativeRuntime = (fn: () => void) => {
3536
let spyNavigator: SpyInstance;
3637

3738
beforeAll(() => {
38-
spyDocument = vi.spyOn(globalThis, 'document', 'get');
39+
spyDocument = jest.spyOn(globalThis, 'document', 'get');
3940
spyDocument.mockReturnValue(undefined);
4041

41-
spyNavigator = vi.spyOn(globalThis.navigator, 'product', 'get');
42+
spyNavigator = jest.spyOn(globalThis.navigator, 'product', 'get');
4243
spyNavigator.mockReturnValue('ReactNative');
4344
});
4445

packages/clerk-js/vitest.config.mts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { resolve } from 'path';
21
import react from '@vitejs/plugin-react';
2+
import { resolve } from 'path';
33
import svgr from 'vite-plugin-svgr';
4-
// For SVG handling
54
import { defineConfig } from 'vitest/config';
65

7-
// Custom plugin to handle SVG imports for testing
86
function viteSvgMockPlugin() {
97
return {
108
name: 'svg-mock',
@@ -25,13 +23,7 @@ function viteSvgMockPlugin() {
2523
}
2624

2725
export default defineConfig({
28-
plugins: [
29-
// Use the React plugin for JSX/TSX transformation
30-
// This replaces ts-jest/swc
31-
react({ jsxRuntime: 'automatic', jsxImportSource: '@emotion/react' }),
32-
svgr(),
33-
viteSvgMockPlugin(),
34-
],
26+
plugins: [react({ jsxRuntime: 'automatic', jsxImportSource: '@emotion/react' }), svgr(), viteSvgMockPlugin()],
3527
define: {
3628
__BUILD_VARIANT_CHIPS__: JSON.stringify(false),
3729
__PKG_NAME__: JSON.stringify('@clerk/clerk-js'),
@@ -52,7 +44,7 @@ export default defineConfig({
5244
'src/**/coverage/**',
5345
'src/**/dist/**',
5446
'src/**/node_modules/**',
55-
'src/(ui|utils|core)/__tests__/**', // Exclude test files themselves
47+
'src/(ui|utils|core)/__tests__/**',
5648
],
5749
},
5850
environment: 'jsdom',
@@ -61,9 +53,6 @@ export default defineConfig({
6153
setupFiles: './vitest.setup.mts',
6254
},
6355
resolve: {
64-
alias: [
65-
// Mirror tsconfig "@/*" → "src/*"
66-
{ find: /^@\//, replacement: `${resolve(__dirname, 'src')}/` },
67-
],
56+
alias: [{ find: /^@\//, replacement: `${resolve(__dirname, 'src')}/` }],
6857
},
6958
});

0 commit comments

Comments
 (0)