chore(config): 更新项目构建与测试配置
- 升级 Next.js 配置,移除 webpackBuildWorker 实验特性 - 更新 Tailwind 设计令牌系统,对齐新品牌色与字体 - 配置 TypeScript strict 模式 (noUncheckedIndexedAccess) - 更新 ESLint 规则与 Jest 测试配置 - 添加 prisma.config.ts 数据库配置
This commit is contained in:
@@ -33,7 +33,8 @@
|
||||
"node_modules/**",
|
||||
"coverage/**",
|
||||
"scripts/**",
|
||||
"config/test/**"
|
||||
"config/test/**",
|
||||
"**/_archive/**"
|
||||
],
|
||||
"globals": {
|
||||
"jest": "readonly"
|
||||
|
||||
@@ -24,7 +24,9 @@ module.exports = {
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
},
|
||||
transform: {
|
||||
'^.+\\.(ts|tsx)$': 'ts-jest',
|
||||
// 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)/)',
|
||||
|
||||
@@ -8,6 +8,46 @@ jest.mock('nanoid', () => ({
|
||||
nanoid: jest.fn(() => 'test-id-123'),
|
||||
}));
|
||||
|
||||
jest.mock('@/generated/prisma/client', () => ({
|
||||
PrismaClient: jest.fn().mockImplementation(() => ({
|
||||
contentItem: {
|
||||
findMany: jest.fn().mockResolvedValue([]),
|
||||
findFirst: jest.fn().mockResolvedValue(null),
|
||||
findUnique: jest.fn().mockResolvedValue(null),
|
||||
},
|
||||
contentModel: {
|
||||
findMany: jest.fn().mockResolvedValue([]),
|
||||
},
|
||||
contentZone: {
|
||||
findMany: jest.fn().mockResolvedValue([]),
|
||||
findUnique: jest.fn().mockResolvedValue(null),
|
||||
},
|
||||
})),
|
||||
}));
|
||||
|
||||
jest.mock('@/lib/cms/data-server', () => ({
|
||||
getPublishedItems: jest.fn().mockResolvedValue([]),
|
||||
getPublishedItemBySlug: jest.fn().mockResolvedValue(null),
|
||||
getItemById: jest.fn().mockResolvedValue(null),
|
||||
getPageZones: jest.fn().mockResolvedValue([]),
|
||||
getZone: jest.fn().mockResolvedValue(null),
|
||||
getContentModels: jest.fn().mockResolvedValue([]),
|
||||
getCases: jest.fn().mockResolvedValue([]),
|
||||
getNews: jest.fn().mockResolvedValue([]),
|
||||
getServices: jest.fn().mockResolvedValue([]),
|
||||
getProducts: jest.fn().mockResolvedValue([]),
|
||||
getSolutions: jest.fn().mockResolvedValue([]),
|
||||
getStats: jest.fn().mockResolvedValue([]),
|
||||
getHeroBanners: jest.fn().mockResolvedValue([]),
|
||||
getCaseBySlug: jest.fn().mockResolvedValue(null),
|
||||
getNewsBySlug: jest.fn().mockResolvedValue(null),
|
||||
getServiceBySlug: jest.fn().mockResolvedValue(null),
|
||||
getProductBySlug: jest.fn().mockResolvedValue(null),
|
||||
getSolutionBySlug: jest.fn().mockResolvedValue(null),
|
||||
getHomePageZones: jest.fn().mockResolvedValue([]),
|
||||
getAllPublishedSlugs: jest.fn().mockResolvedValue([]),
|
||||
}));
|
||||
|
||||
jest.mock('next/dynamic', () => ({
|
||||
__esModule: true,
|
||||
default: (importFn, options) => {
|
||||
|
||||
Reference in New Issue
Block a user