- BFF 薄适配层(FastAPI,8090):QA 代理/SSE 中继/Neo4j 直连/抽取代理/会话持久化 - Vue3 前端:五相位检索流水线、文献来源与证据链、知识图谱、提取任务四 tab - 四档响应式(桌面/笔记本/平板/手机)、深浅主题 - 81 个 FR 全部实现,测试追溯矩阵 81/81,后端 121 测/前端 156 测 - 真实凭据已脱敏,运行时配置在 backend/.env(不入 git) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
40 lines
1.7 KiB
JavaScript
40 lines
1.7 KiB
JavaScript
// vitest.config.js —— B1 归属。单测配置(jsdom + @vue/test-utils)。
|
||
// 测试文件位于项目根 tests/frontend/unit(frontend/ 之外),依赖解析自 frontend/node_modules:
|
||
// - server.fs.allow 放行上级目录
|
||
// - include 用绝对路径(与运行 cwd 无关)
|
||
// - 测试文件中的裸导入(pinia/vue/@vue/test-utils)以 alias 指到 frontend/node_modules 的 ESM 入口
|
||
// 运行方式(任选):
|
||
// cd frontend && npx vitest run tests/frontend/unit/b1
|
||
// 或项目根:npx --prefix frontend vitest run --config frontend/vitest.config.js tests/frontend/unit/b1
|
||
import { fileURLToPath } from 'node:url';
|
||
import { defineConfig } from 'vitest/config';
|
||
import vue from '@vitejs/plugin-vue';
|
||
|
||
const nodeModules = fileURLToPath(new URL('./node_modules', import.meta.url));
|
||
const testsDir = fileURLToPath(new URL('../tests/frontend/unit', import.meta.url));
|
||
|
||
export default defineConfig({
|
||
plugins: [vue()],
|
||
// 独立依赖缓存目录:避免与 dev server(node_modules/.vite)争用 optimizeDeps 锁
|
||
cacheDir: 'node_modules/.vite-vitest',
|
||
resolve: {
|
||
alias: {
|
||
// 测试文件在 frontend/ 外,裸包名解析不到 frontend/node_modules
|
||
pinia: `${nodeModules}/pinia/dist/pinia.mjs`,
|
||
vue: `${nodeModules}/vue/index.mjs`,
|
||
'@vue/test-utils': `${nodeModules}/@vue/test-utils/dist/vue-test-utils.esm-bundler.mjs`,
|
||
},
|
||
},
|
||
server: {
|
||
// 测试文件位于项目根 tests/(frontend/ 之外),放行上级目录
|
||
fs: { allow: ['..'] },
|
||
},
|
||
test: {
|
||
environment: 'jsdom',
|
||
// 测试目录在项目根 tests/frontend/unit(B1/B2/B3 各自子树)
|
||
include: [`${testsDir}/**/*.{test,spec}.js`],
|
||
globals: false,
|
||
setupFiles: [`${testsDir}/b1/setup.js`],
|
||
},
|
||
});
|