該賞金到期in 4天。這個問題的答案有資格獲得 50聲望獎勵。 斯里想引起對這個問題的更多關注。
我通過使用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 集成到這樣的專案中?
uj5u.com熱心網友回復:
更新 jest 配置以準確定義 tsconfig 檔案ts-jest:
package.json
{
"jest": {
"preset": "ts-jest",
"environment": "node",
"globals": {
"ts-jest": {
"tsconfig": "./tests/tsconfig.json"
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/341084.html
