65726702f3
Co-Authored-By: Claude Code <noreply@anthropic.com>
30 lines
1012 B
JavaScript
30 lines
1012 B
JavaScript
/** @type {import('jest').Config} */
|
||
module.exports = {
|
||
testEnvironment: 'node',
|
||
// 包为 ESM("type": "module"),Jest 以 CJS 运行测试:
|
||
// 用内联 tsconfig 覆盖 module/moduleResolution(NodeNext 会按包类型产出 ESM)。
|
||
// Task 6 的类型测试沿用此配置。
|
||
transform: {
|
||
'^.+\\.tsx?$': [
|
||
'ts-jest',
|
||
{
|
||
tsconfig: {
|
||
module: 'commonjs',
|
||
moduleResolution: 'node10',
|
||
target: 'es2022',
|
||
strict: true,
|
||
esModuleInterop: true,
|
||
// 覆盖包级 tsconfig 的 types 限制(其值仅供 src 构建侧收敛 node 类型):
|
||
// 测试编译需要 jest 全局与 node 类型(internal-sync 的 Buffer/测试时钟)。
|
||
types: ['node', 'jest'],
|
||
},
|
||
},
|
||
],
|
||
},
|
||
// TS 源码使用 NodeNext 风格的 .js 扩展导入,运行时映射回 .ts。
|
||
moduleNameMapper: {
|
||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
||
},
|
||
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
|
||
};
|