- 配置Jest测试框架 - 添加字段池管理器测试(field-pool.test.ts) * 测试选项值清洗功能(normalizeFieldOptionValue) * 测试选项解析功能(parseOptionsStatic) * 测试选项展开功能(expandOptionValue) * 覆盖边界情况和特殊字符处理 - 添加模板验证器测试(template-validator.test.ts) * 测试模板ID验证(validateTemplateId) * 测试内置模板识别(isBuiltinTemplate) * 测试模板key提取(extractBuiltinTemplateKey) * 测试错误处理和日志记录 - 更新package.json添加测试脚本 - 所有43个测试用例通过
29 lines
804 B
JavaScript
29 lines
804 B
JavaScript
const nextJest = require('next/jest')
|
|
|
|
const createJestConfig = nextJest({
|
|
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
|
|
dir: './',
|
|
})
|
|
|
|
// Add any custom config to be passed to Jest
|
|
const customJestConfig = {
|
|
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
|
testEnvironment: 'jest-environment-node',
|
|
moduleNameMapper: {
|
|
'^@/(.*)$': '<rootDir>/$1',
|
|
},
|
|
testMatch: [
|
|
'**/__tests__/**/*.test.ts',
|
|
'**/__tests__/**/*.test.tsx',
|
|
],
|
|
collectCoverageFrom: [
|
|
'lib/**/*.{ts,tsx}',
|
|
'app/api/**/*.{ts,tsx}',
|
|
'!**/*.d.ts',
|
|
'!**/node_modules/**',
|
|
],
|
|
}
|
|
|
|
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
|
|
module.exports = createJestConfig(customJestConfig)
|