Cannot find name 'describe'. Do you need to install type definitions for a test runner? Cannot find name 'describe'. Do you need to install type definitions for a test runner? typescript typescript

Cannot find name 'describe'. Do you need to install type definitions for a test runner?


I'm using VSCode as my IDE and in my Angular project, I had to comment-out/remove types in tsconfig.json and add jest in types at tsconfig.spec.json.

tsconfig.json

{  "compilerOptions": {    // "types": []  }}

tsconfig.spec.json

{  "compilerOptions": {    "types": ["jest", "node"]  }}


Simple checklist to solve this (for TypeScript and Jest).

  1. Make sure you have @types/jest and @types/node installed.
  2. Make sure you have linked these types in tsconfig.json so that: types: ["jest", "node"]
  3. Make sure you don't have your tests or the tests directory excluded from tsconfig.json configuration in excluded property.

If you transpile to JS then you will need a separate tsconfig.json in your tests that includes your test files along with the necessary compiler options and files to build the appropriate context.


None of the above fixed my issue.I had to add "@types/jest" to the types array in the tsconfig.json file.