ERROR in error TS2688: Cannot find type definition file for 'jest'

19,196

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.

Share:
19,196
Ricardo Rocha
Author by

Ricardo Rocha

🧐 Who is this man? πŸ’» Full Stack Web Developer and in love with javascript and everything around. πŸ‘¨β€πŸ’» Works daily with C#, angular, and SQL and likes it! ✨ Deep learning enthusiastic, especially if works with javascript πŸ˜€ πŸ“š Learn addicted. πŸ€“ Proud nerd! 🎷 Saxophone player.

Updated on June 13, 2022

Comments

  • Ricardo Rocha
    Ricardo Rocha almost 2 years

    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?

  • simbro
    simbro about 4 years
    Adding "node" to my "types" array in tsconfig.json worked for me - not sure why - but it worked! thanks.
  • Utpal Dutt
    Utpal Dutt over 2 years
    @simbro how did you even came up with that ? why node ?