【发布时间】:2021-10-29 09:56:42
【问题描述】:
我使用references 和composite 设置分隔了jest 的测试类型和项目类型。但是 ts-jest 无法在测试文件中找到类型信息并抛出多个错误,例如:error TS2304: Cannot find name 'expect'。
这是目录结构:
.
├── package.json
├── src
│ └── index.ts
├── tests
│ ├── index.test.ts
│ └── tsconfig.json
├── tsconfig.json
tsconfig.json:
{
"compilerOptions": {
"composite": true,
},
"include": ["src"]
}
tests/tsconfig.json:
{
"extends": "../tsconfig.json",
"references": [
{
"name": "my-lib",
"path": ".."
}
],
"compilerOptions": {
"types": ["jest"],
"rootDir": "..",
"noEmit": true
},
"include": ["."]
}
package.json:
{
"jest": {
"preset": "ts-jest",
"environment": "node"
}
}
如何在这样的项目中集成 ts-jest?
【问题讨论】:
标签: node.js typescript testing jestjs ts-jest