34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import path from 'node:path';
|
||
import { defineConfig } from 'vitest/config';
|
||
|
||
export default defineConfig({
|
||
resolve: {
|
||
alias: {
|
||
'lottie-react-native': path.resolve(__dirname, '__tests__/mocks/lottieReactNative.tsx'),
|
||
'react-native-gesture-handler': path.resolve(__dirname, '__tests__/mocks/react-native-gesture-handler.ts'),
|
||
'react-native-safe-area-context': path.resolve(__dirname, '__tests__/mocks/react-native-safe-area-context.ts'),
|
||
'@telescope/proxy-runtime': path.resolve(__dirname, '../proxy-runtime/src/index.ts'),
|
||
},
|
||
// 强制 React 在整个测试图中只有一个实例。
|
||
// @telescope/hooks 包有自己的 node_modules/react 副本,导致 ahooks 子路径
|
||
// 导入时拿到不同的 ReactCurrentDispatcher,react-test-renderer 渲染时
|
||
// dispatcher 为 null,触发 "Cannot read properties of null (reading 'useRef')"。
|
||
dedupe: ['react', 'react-native'],
|
||
},
|
||
test: {
|
||
include: ['__tests__/**/*.test.ts', '__tests__/**/*.test.tsx'],
|
||
exclude: ['node_modules', 'android', 'ios', 'dist', 'src-tauri'],
|
||
environment: 'node',
|
||
globals: true,
|
||
setupFiles: ['./__tests__/setup.ts'],
|
||
clearMocks: true,
|
||
restoreMocks: true,
|
||
testTimeout: 15000,
|
||
coverage: {
|
||
provider: 'v8',
|
||
all: true,
|
||
include: [],
|
||
},
|
||
},
|
||
});
|