I have an angular 6 application and I'm using karma + jasmine to run my tests. but when I run ng test
I'm getting the following error:
ERROR in error TS2688: Cannot find type definition file for 'jest'.
Any one knows how to solve this problem?
I have an angular 6 application and I'm using karma + jasmine to run my tests. but when I run ng test
I'm getting the following error:
ERROR in error TS2688: Cannot find type definition file for 'jest'.
Any one knows how to solve this problem?
I didn't realized that in my tsconfig.spec.json
I was using jest
instead of jasmin
in types
node. Also, I had a missing configuration.
So, I have changed from this:
{
"extends": "./tsconfig.es5.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es6",
"baseUrl": "",
"types": [
"jest",
"node"
]
},
"files": [
"**/*.spec.ts"
]
}
To this:
{
"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"
]
}
And this changes solves my problem.
As of Aug 2023, if you are using the latest version of @testing-library/jest-dom
, all you need to do is remove @types/testing-library_jest-dom
.
I didn't realized that in my tsconfig.spec.json
I was using jest
instead of jasmin
in types
node. Also, I had a missing configuration.
So, I have changed from this:
{
"extends": "./tsconfig.es5.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es6",
"baseUrl": "",
"types": [
"jest",
"node"
]
},
"files": [
"**/*.spec.ts"
]
}
To this:
{
"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"
]
}
And this changes solves my problem.
© 2022 - 2024 — McMap. All rights reserved.