Issue
I have an Angular 9 app and just added a small unit test to a component. But VSCode doesn't recognize the types like describe
, beforeEach
, it
. Although I have a tsconfig.spec.json file which has jasmine
in its types
definition:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": ["jasmine", "node", "jest"]
},
"files": ["src/test.ts", "src/polyfills.ts"],
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
}
The actual error I get is the following:
Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.ts(2582)
What I've tried (but didn't work)
- Reinstall
@types/jasmine
viayarn add -D @types/jasmine
- Add
jasmine
totypes
of tsconfig.json - Remove the
types
definitions from tsconfig.spec.json - Reinstall all the dependencies of my project
- Add
jasmine
totypes
of the tsconfig.json in the root of my monorepo
Try it yourself
If you want to take a closer look you can try it yourself by
git clone https://github.com/flolu/cents-ideas
git checkout 45bda5235f832ab801d6439d0179dd6c0e76c4cc
Then /services/client/src/app/hello-world/hello-world.component.spec.ts
is the file with the errors
Sidenote: The test passes, so it is just a problem with VSCode not finding the types.