Files
2026-09-18 15:21:41 +08:00

30 lines
1012 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** @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/'],
};