xingyun/vitest.config.ts

34 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 子路径
// 导入时拿到不同的 ReactCurrentDispatcherreact-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: [],
},
},
});