VSCode isn't recognizing Jest types. I'm getting the following error:
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` and then add `jest` or `mocha` to the types field in your tsconfig.
I have installed @types/jest
and added jest
to the types
field in my tsconfig
file but it's not working.
I notice, however, it only happens for subdirectories as I have a monorepo with the following file structure:
- app1
- app2
- app3
If I open only the app1
folder, then I don't get any errors. How can I setup VSCode to work with a folder having multiple projects?
I know VSCode allow us to set up multiple workspaces but that's not what I'm looking for. Every folder has their own node_modules
and a tsconfig
file. I just want VSCode to recognize them for every folder rather than looking at the root level for node_modules
.
I've also tried to create a tsconfig
file at the root level adding this:
{
"compilerOptions": {
"typeRoots": ["app1/node_modules/@types", "app2/node_modules/@types"]
}
}
But it didn't work.