chore: directory migration - gateway→server, web→client/electron

This commit is contained in:
2026-09-08 19:16:35 +08:00
parent fd9f99a3f9
commit f9d757b5e5
243 changed files with 5095 additions and 228 deletions

View File

@ -0,0 +1,31 @@
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
/**
* 组件测试配置。
*
* 与 vite.config.ts 分开:那份是构建与开发服务器的配置,插件链和 test 段混在
* 一起时 `vite build` 也会解析 jsdom 这些只有测试才需要的依赖。
*
* 只跑 test/components/ 下的用例。test/ 顶层那几个(markdown-xss、
* narrow-layout)是 node:test / 手写断言脚本,由 `npm test` 直接用 node 跑 ——
* 它们不需要 DOM,套一层 vitest 只是变慢。
*/
export default defineConfig({
// 测试必须使用含 act() 的 React 开发构建;宿主进程可能继承 NODE_ENV=production。
define: {
'process.env.NODE_ENV': JSON.stringify('test')
},
plugins: [react()],
test: {
include: ['test/components/**/*.test.tsx'],
environment: 'jsdom',
globals: true,
setupFiles: ['test/components/setup.ts'],
// 每个文件跑完清掉 DOM 与 mock,避免上一个用例的残留影响下一个
restoreMocks: true,
clearMocks: true,
unstubEnvs: true,
unstubGlobals: true
}
});