Files
hfb_sys/frontend/package.json
T
yml 965832c3cb 前端测试基建: vitest.config + jsdom + test script, 3 个死 spec 复活
现状: vitest 已装, 3 个 spec 已存在 (listings composables, 14 用例), 但跑不起来——package.json 无 test script, 无 vitest.config, @/ 别名在测试环境不通 (Cannot find package '@/...')。

修复:
- 新增 vitest.config.ts: jsdom 环境 (提供 window/document/navigator, 让 monitor.ts 等浏览器模块可加载) + @ 别名 (与 vite.config.ts 同口径) + globals + v8 coverage 配置
- package.json 加 test / test:watch / test:coverage script
- 装 jsdom devDependency
- check.sh 前端门禁加 npm run test 步骤 (受 --skip-tests 控制, 与后端测试一致)

验证: npm run test 3 spec 全过 (14 用例); check.sh --skip-backend 全绿 (check + test + build)。

之前 "有测试实际跑不起来" 的债务清掉。后续 composable/api 层测试可直接 npm run test。
2026-06-14 18:13:06 +08:00

53 lines
1.5 KiB
JSON

{
"name": "hfb-sys-frontend",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vue-tsc -b --noEmit --watch & vite --host 0.0.0.0",
"build": "vue-tsc -b --noEmit && vite build",
"preview": "vite preview --host 0.0.0.0",
"typecheck": "vue-tsc -b --noEmit",
"lint": "eslint .",
"lint:strict": "eslint . --max-warnings=0",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"format:check": "prettier --check .",
"check": "npm run format:check && npm run lint:strict && npm run typecheck",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"axios": "^1.13.2",
"element-plus": "^2.11.9",
"marked": "^18.0.5",
"pinia": "^3.0.4",
"qrcode": "^1.5.4",
"vue": "^3.5.24",
"vue-router": "^4.6.3"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@types/node": "^24.10.1",
"@types/qrcode": "^1.5.6",
"@vant/auto-import-resolver": "^1.3.0",
"@vitejs/plugin-vue": "^6.0.2",
"@vue/tsconfig": "^0.8.1",
"eslint": "^10.4.1",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-vue": "^10.9.2",
"globals": "^17.6.0",
"jsdom": "^29.1.1",
"prettier": "^3.8.3",
"typescript": "~5.9.3",
"typescript-eslint": "^8.60.1",
"unplugin-auto-import": "^21.0.0",
"unplugin-vue-components": "^32.1.0",
"vant": "^4.9.24",
"vite": "^7.2.4",
"vitest": "^4.1.8",
"vue-tsc": "^3.1.5"
}
}