Files
crawler-plugin/frontend-vue/vitest.config.ts
T
huangzd1997 84ae94b6c6 feat(用户端护栏): 首批组件挂载测试 + 铃铛标已读失败改可见(§2「0 挂载测试」那一半句闭掉)
- vitest.config.ts 与 vite.config.ts 分家:只服务 tests/mount/**,不进 tsconfig include,npm run build 产物不受影响(vue-tsc --noEmit rc=0 实测)
- tests/mount/notification-bell-failure.mount.test.ts 三支:标已读失败必须给带原因的错误提示且不许把行冒充成已读;成功时不产生提示且行真转已读;列表失败文案进面板本身而不弹全局消息
- NotificationBell.vue 的 onItemClick 改前只 console.warn(点了通知没反应、行也不转已读),现与 readAll 同走 ElMessage.error;反证:摘掉这行出口 ⇒ 挂载例判红(实测 1 failed 2 passed)
- 依赖只加 devDependencies(vitest/@vue/test-utils/happy-dom),运行时四项 lock 版本与 HEAD 逐一对等 ⇒ 生产构建输入未变
- 面板是 Teleport 到 body:wrapper.find 看不见里面的行,改从 document 取节点用原生 click 触发(实测踩过)
- npm test 那支不递归的 glob 仍 762 例 0 红,两套 runner 互不抓取
2026-10-09 11:21:47 +08:00

27 lines
1.1 KiB
TypeScript
Raw 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 { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
/**
* 组件挂载测试的独立配置(四面9分口径 §2 用户端「错误静默 …;0 挂载测试」那一半)。
*
* 与 vite.config.ts 分家:那份管生产构建,这里只服务挂载用例,
* 动它不改变 `npm run build` 的产物,也不在 tsconfig include 里(vue-tsc 不检它)。
* include 只收 `tests/mount/**`——本仓其余判据走 `node --test tests/*.test.ts`,
* 那支 glob 不递归,两套 runner 抓不到对方的文件(后管同款分法,已验证互不串)。
*/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
test: {
// 本面装的是 happy-dom(后管那份用 jsdom):环境名写错时 vitest 直接 MISSING DEPENDENCY,
// 一支用例都跑不起来还报 "no tests"——所以这条与 devDependencies 必须同处对账。
environment: 'happy-dom',
include: ['tests/mount/**/*.test.ts'],
},
})