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:
+3
-112
@@ -1,112 +1,3 @@
|
||||
// @ts-nocheck
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'jsdom',
|
||||
roots: ['<rootDir>/src'],
|
||||
testMatch: ['**/__tests__/**/*.test.{ts,tsx}', '**/*.test.{ts,tsx}'],
|
||||
// 仅收集实际可单元测试的目录的覆盖率,排除 pages/API routes/admin 等需集成/E2E 测试的代码
|
||||
collectCoverageFrom: [
|
||||
'src/components/ui/**/*.{ts,tsx}',
|
||||
'src/components/layout/**/*.{ts,tsx}',
|
||||
'src/components/seo/**/*.{ts,tsx}',
|
||||
'src/components/detail/**/*.{ts,tsx}',
|
||||
'src/components/sections/**/*.{ts,tsx}',
|
||||
'src/components/content/**/*.{ts,tsx}',
|
||||
'src/hooks/**/*.{ts,tsx}',
|
||||
'src/lib/**/*.ts',
|
||||
'!src/**/*.d.ts',
|
||||
'!src/**/*.stories.{ts,tsx}',
|
||||
'!src/**/__tests__/**',
|
||||
],
|
||||
// 覆盖率阈值采用渐进提升策略:基于 Phase 1-5 实测值设定目录级阈值,避免全局平均掩盖核心模块缺口
|
||||
// 实测基准 (Phase 5): global(~33% stmts/~32% branches), hooks(~61%/~41%), lib(~45%/~43%),
|
||||
// ui(~15%/~21%), layout(~59%/~48%), detail(~32%/~29%), sections(~31%/~35%), content(~29%/~5%),
|
||||
// lib/cms(~67%/~83%), lib/constants(~94%/~81%)
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
branches: 30,
|
||||
functions: 25,
|
||||
lines: 32,
|
||||
statements: 30,
|
||||
},
|
||||
'./src/hooks/': {
|
||||
branches: 38,
|
||||
functions: 60,
|
||||
lines: 60,
|
||||
statements: 60,
|
||||
},
|
||||
'./src/lib/': {
|
||||
branches: 40,
|
||||
functions: 45,
|
||||
lines: 42,
|
||||
statements: 42,
|
||||
},
|
||||
'./src/components/ui/': {
|
||||
branches: 18,
|
||||
functions: 10,
|
||||
lines: 15,
|
||||
statements: 14,
|
||||
},
|
||||
'./src/components/layout/': {
|
||||
branches: 45,
|
||||
functions: 35,
|
||||
lines: 60,
|
||||
statements: 55,
|
||||
},
|
||||
'./src/components/detail/': {
|
||||
branches: 25,
|
||||
functions: 22,
|
||||
lines: 30,
|
||||
statements: 30,
|
||||
},
|
||||
'./src/components/sections/': {
|
||||
branches: 30,
|
||||
functions: 18,
|
||||
lines: 30,
|
||||
statements: 30,
|
||||
},
|
||||
'./src/components/content/': {
|
||||
branches: 4,
|
||||
functions: 4,
|
||||
lines: 25,
|
||||
statements: 25,
|
||||
},
|
||||
'./src/components/seo/': {
|
||||
branches: 0,
|
||||
functions: 18,
|
||||
lines: 40,
|
||||
statements: 40,
|
||||
},
|
||||
'./src/lib/cms/': {
|
||||
branches: 80,
|
||||
functions: 75,
|
||||
lines: 60,
|
||||
statements: 65,
|
||||
},
|
||||
'./src/lib/constants/': {
|
||||
branches: 88,
|
||||
functions: 45,
|
||||
lines: 85,
|
||||
statements: 85,
|
||||
},
|
||||
},
|
||||
coverageProvider: 'v8',
|
||||
coverageReporters: ['text', 'lcov', 'html', 'json'],
|
||||
coverageDirectory: '<rootDir>/coverage',
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
},
|
||||
transform: {
|
||||
// ts-jest 需要明确指定 jsx: 'react-jsx',因为项目 tsconfig 使用 'preserve'
|
||||
// 由后续 SWC/Babel 处理,但 Jest 环境下没有这些工具链
|
||||
'^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: { jsx: 'react-jsx' } }],
|
||||
},
|
||||
transformIgnorePatterns: [
|
||||
'node_modules/(?!(nanoid|next-auth|@auth|@aws-sdk)/)',
|
||||
],
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
||||
testTimeout: 10000,
|
||||
verbose: true,
|
||||
maxWorkers: '50%',
|
||||
};
|
||||
// Jest 配置单一真源在 config/test/jest.config.js(同时被 stryker 与 test:integration 使用)。
|
||||
// 根目录留一份转发,避免 `jest`(默认读根配置)与 `jest --config config/test/...` 走两套阈值。
|
||||
module.exports = require('./config/test/jest.config.js');
|
||||
|
||||
Reference in New Issue
Block a user