template/vitest.perf.config.ts
unanmed 37bf89bc94 test(06-16): add isolated perf channel and critical calculation perf
- vitest.perf.config.ts: include only *.perf.ts, mirror vite.config.ts aliases, 30s timeouts
- package.json: add test:perf script (test/test:ci untouched)
- damage.perf.ts: 3 cases (1000/10000/50000) warmup 3 + 20 samples, no assertions
2026-09-16 14:56:28 +08:00

34 lines
1.1 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.

// 性能测量专用 vitest 配置:仅收集 *.perf.ts与默认 test:ci 通道完全隔离
import { defineConfig } from 'vitest/config';
import path from 'path';
import * as glob from 'glob';
// 镜像 vite.config.ts 的核心包别名计算node_modules 下没有 @motajs/* 与 @user/*
const aliases = glob.sync('packages/*/src').map(srcPath => {
const packageName = path.basename(path.dirname(srcPath));
return {
find: `@motajs/${packageName}`,
replacement: path.resolve(__dirname, srcPath)
};
});
// 镜像 vite.config.ts 的用户包别名计算,保证 perf 文件及其传递依赖可解析
const aliasesUser = glob.sync('packages-user/*/src').map(srcPath => {
const packageName = path.basename(path.dirname(srcPath));
return {
find: `@user/${packageName}`,
replacement: path.resolve(__dirname, srcPath)
};
});
export default defineConfig({
resolve: {
alias: [...aliases, ...aliasesUser]
},
test: {
include: ['**/*.perf.ts'],
testTimeout: 30000,
hookTimeout: 30000
}
});