【发布时间】:2019-05-11 13:46:39
【问题描述】:
我有一个 Angular 6 应用程序,我正在使用 karma + jasmine 来运行我的测试。但是当我运行ng test 时出现以下错误:
错误 TS2688 中的错误:找不到“jest”的类型定义文件。
有人知道如何解决这个问题吗?
【问题讨论】:
标签: angular jasmine angular6 angular-cli karma-runner
我有一个 Angular 6 应用程序,我正在使用 karma + jasmine 来运行我的测试。但是当我运行ng test 时出现以下错误:
错误 TS2688 中的错误:找不到“jest”的类型定义文件。
有人知道如何解决这个问题吗?
【问题讨论】:
标签: angular jasmine angular6 angular-cli karma-runner
我没有意识到在我的tsconfig.spec.json 中我使用的是jest 而不是jasmin 节点中的jasmin。另外,我缺少配置。
所以,我已经改变了:
{
"extends": "./tsconfig.es5.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es6",
"baseUrl": "",
"types": [
"jest",
"node"
]
},
"files": [
"**/*.spec.ts"
]
}
到这里:
{
"extends": "./tsconfig.es5.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "../out-tsc/spec",
"module": "commonjs",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
而这个改变解决了我的问题。
【讨论】: