45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
|
|
import { resolve } from 'node:path';
|
||
|
|
import { fileURLToPath } from 'node:url';
|
||
|
|
import { configDefaults, defineConfig, mergeConfig } from 'vitest/config';
|
||
|
|
import viteConfig from './vite.config';
|
||
|
|
|
||
|
|
export default defineConfig(configEnv =>
|
||
|
|
mergeConfig(
|
||
|
|
viteConfig(configEnv),
|
||
|
|
defineConfig({
|
||
|
|
// eslint-disable-next-line node/prefer-global/process
|
||
|
|
optimizeDeps: process.env.FILE_TEST
|
||
|
|
? ({
|
||
|
|
exclude: ['@busi-comp', '@lingshu/core-utils'],
|
||
|
|
})
|
||
|
|
: undefined,
|
||
|
|
test: {
|
||
|
|
environment: 'jsdom',
|
||
|
|
exclude: [...configDefaults.exclude, 'e2e/**'],
|
||
|
|
root: fileURLToPath(new URL('./', import.meta.url)),
|
||
|
|
deps: {
|
||
|
|
inline: ['vue'], // 如果被测试的内容有包含vue的,需要配置这个
|
||
|
|
},
|
||
|
|
// eslint-disable-next-line node/prefer-global/process
|
||
|
|
alias: process.env.FILE_TEST
|
||
|
|
? {
|
||
|
|
'@busi-comp': resolve(__dirname, '../business-components/src'),
|
||
|
|
'@lingshu/core-utils': resolve(__dirname, '../../packages/core-utils/src/index.ts'),
|
||
|
|
}
|
||
|
|
: undefined,
|
||
|
|
coverage: {
|
||
|
|
reporter: ['text', 'json', 'html'],
|
||
|
|
include: ['**/src/**/*.ts'],
|
||
|
|
exclude: ['**/node_modules/**', '**/tests/**'],
|
||
|
|
thresholds: {
|
||
|
|
lines: 100, // 行覆盖率
|
||
|
|
functions: 100, // 函数覆盖率
|
||
|
|
branches: 100, // 分支覆盖率
|
||
|
|
statements: 100, // 语句覆盖率
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
}),
|
||
|
|
),
|
||
|
|
);
|