test(qa): e2e 装配修正 + 集成/门禁测试与工具链重构
- e2e:修死选择器与蜜罐误命中、补断言、GA4/security-headers 用例诚实标注 skip 边界;新增 assert-helpers/fixtures/hydrated/primary-nav/touch-targets 等复用桩。 - 集成层:config/test/jest.integration.config.js + tests-integration/ 真库 一次性 SQLite 用例,teardown 守卫开发库指纹。 - 门禁工具链:jest.setup 归位到根、scripts/accessibility 全站 axe 节点计数、 check-brand-text-token/check-motion-constraints 机械守卫、stryker/lighthouse 配置收敛。
This commit is contained in:
+75
-74
@@ -16,96 +16,91 @@ module.exports = {
|
||||
'src/components/sections/**/*.{ts,tsx}',
|
||||
'src/components/content/**/*.{ts,tsx}',
|
||||
'src/components/analytics/**/*.{ts,tsx}',
|
||||
'src/components/cms/**/*.{ts,tsx}',
|
||||
'src/hooks/**/*.{ts,tsx}',
|
||||
'src/lib/**/*.ts',
|
||||
'!src/**/*.d.ts',
|
||||
'!src/**/*.stories.{ts,tsx}',
|
||||
'!src/**/__tests__/**',
|
||||
],
|
||||
// 覆盖率阈值采用渐进提升策略:基于 Phase 7 实测值设定目录级阈值,避免全局平均掩盖核心模块缺口
|
||||
// 实测基准 (Phase 7 — 2026-08-02): global(72.65% stmts/82.20% branches/73.56% funcs),
|
||||
// ui(63.91%/76.52%), layout(71.02%/76.92%), detail(74.20%/75.96%), sections(43.24%/78.09%),
|
||||
// seo(100%/100%), content(56.15%/100%), analytics(已覆盖全部 7 组件),
|
||||
// lib(95.96%/89.60%), lib/cms(91.22%/90.90%), lib/constants(98.78%/91.89%)
|
||||
// 覆盖率棘轮(验收 A-7):阈值取自实测值下调 3–5 个点,只允许上升。
|
||||
// 本文件是阈值的单一真源;根 jest.config.js 仅转发(旧注释曾把路径写成 config/test/ 之外的地方,已纠)。
|
||||
// 复测命令:npm run test:coverage(最近一次 2026-09-23,134 suites / 1697 tests,EXIT=0)
|
||||
// 实测 global: stmts 85.56 / branch 86.86 / funcs 80.59 / lines 85.56
|
||||
// 目录级最近实测:components/content 100/100/100/100 · components/sections 72.77/87.06/73.8/72.77 · lib/cms 91.9/92.63/92.5/91.9
|
||||
// ⚠ 口径提示:global 四项实测已比门限高 5.6–10.6 个点,即棘轮当前偏松(低于「实测 −5pp」的本文件自订策略)。
|
||||
// 上调是独立动作,须与「哪些目录仍可约束」一起评估,不与功能变更混提。
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
branches: 70,
|
||||
functions: 55,
|
||||
lines: 55,
|
||||
statements: 55,
|
||||
branches: 82,
|
||||
functions: 75,
|
||||
lines: 75,
|
||||
statements: 75,
|
||||
},
|
||||
'./src/hooks/': {
|
||||
branches: 38,
|
||||
functions: 60,
|
||||
lines: 60,
|
||||
statements: 60,
|
||||
branches: 88,
|
||||
functions: 85,
|
||||
lines: 88,
|
||||
statements: 88,
|
||||
},
|
||||
'./src/lib/': {
|
||||
branches: 40,
|
||||
functions: 45,
|
||||
lines: 42,
|
||||
statements: 42,
|
||||
},
|
||||
'./src/components/ui/': {
|
||||
branches: 45,
|
||||
functions: 55,
|
||||
lines: 35,
|
||||
statements: 35,
|
||||
},
|
||||
'./src/components/layout/': {
|
||||
branches: 60,
|
||||
functions: 35,
|
||||
lines: 60,
|
||||
statements: 60,
|
||||
},
|
||||
'./src/components/detail/': {
|
||||
branches: 60,
|
||||
functions: 45,
|
||||
lines: 60,
|
||||
statements: 60,
|
||||
},
|
||||
'./src/components/sections/': {
|
||||
branches: 60,
|
||||
functions: 30,
|
||||
lines: 35,
|
||||
statements: 35,
|
||||
},
|
||||
'./src/components/content/': {
|
||||
branches: 80,
|
||||
functions: 40,
|
||||
lines: 45,
|
||||
statements: 45,
|
||||
},
|
||||
'./src/components/analytics/': {
|
||||
branches: 30,
|
||||
functions: 40,
|
||||
lines: 35,
|
||||
statements: 35,
|
||||
},
|
||||
'./src/components/cms/': {
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80,
|
||||
},
|
||||
'./src/components/seo/': {
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80,
|
||||
branches: 86,
|
||||
functions: 85,
|
||||
lines: 92,
|
||||
statements: 92,
|
||||
},
|
||||
'./src/lib/cms/': {
|
||||
branches: 80,
|
||||
functions: 75,
|
||||
lines: 60,
|
||||
statements: 65,
|
||||
branches: 86,
|
||||
functions: 86,
|
||||
lines: 88,
|
||||
statements: 88,
|
||||
},
|
||||
'./src/lib/constants/': {
|
||||
branches: 88,
|
||||
functions: 45,
|
||||
lines: 85,
|
||||
statements: 85,
|
||||
functions: 55,
|
||||
lines: 92,
|
||||
statements: 92,
|
||||
},
|
||||
'./src/components/ui/': {
|
||||
branches: 74,
|
||||
functions: 76,
|
||||
lines: 62,
|
||||
statements: 62,
|
||||
},
|
||||
'./src/components/layout/': {
|
||||
branches: 66,
|
||||
functions: 46,
|
||||
lines: 82,
|
||||
statements: 82,
|
||||
},
|
||||
'./src/components/detail/': {
|
||||
branches: 80,
|
||||
functions: 42,
|
||||
lines: 80,
|
||||
statements: 80,
|
||||
},
|
||||
'./src/components/sections/': {
|
||||
branches: 72,
|
||||
functions: 50,
|
||||
lines: 44,
|
||||
statements: 44,
|
||||
},
|
||||
'./src/components/content/': {
|
||||
branches: 95,
|
||||
functions: 46,
|
||||
lines: 52,
|
||||
statements: 52,
|
||||
},
|
||||
'./src/components/analytics/': {
|
||||
branches: 82,
|
||||
functions: 86,
|
||||
lines: 94,
|
||||
statements: 94,
|
||||
},
|
||||
'./src/components/seo/': {
|
||||
branches: 95,
|
||||
functions: 95,
|
||||
lines: 95,
|
||||
statements: 95,
|
||||
},
|
||||
},
|
||||
coverageProvider: 'v8',
|
||||
@@ -119,9 +114,15 @@ module.exports = {
|
||||
// ts-jest 需要明确指定 jsx: 'react-jsx',因为项目 tsconfig 使用 'preserve'
|
||||
// 由后续 SWC/Babel 处理,但 Jest 环境下没有这些工具链
|
||||
'^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: { jsx: 'react-jsx' } }],
|
||||
// sanitize-html 的解析器链(htmlparser2 v12 起)为 ESM-only,Node 可靠 require(esm) 加载,
|
||||
// Jest 的 CJS 运行时不行,须显式转译(作用域限定在这几个包,不影响其余 node_modules)
|
||||
'node_modules/(?:htmlparser2|domhandler|domutils|dom-serializer|domelementtype|entities)/.+\\.js$': [
|
||||
'ts-jest',
|
||||
{ tsconfig: { allowJs: true, checkJs: false, module: 'commonjs', esModuleInterop: true, target: 'es2020' } },
|
||||
],
|
||||
},
|
||||
transformIgnorePatterns: [
|
||||
'node_modules/(?!(nanoid|next-auth|@auth|@aws-sdk)/)',
|
||||
'node_modules/(?!(nanoid|next-auth|@auth|@aws-sdk|htmlparser2|domhandler|domutils|dom-serializer|domelementtype|entities)/)',
|
||||
],
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
||||
testTimeout: 10000,
|
||||
|
||||
Reference in New Issue
Block a user