I am trying to get vitest globals api to work so I can write describe, test and expect functions without importing them in each test file like in jest.
I have managed to get tests passing by following the guide but I am getting red errors lines when calling the vitest functions in vs-code.
E.g.
Cannot find name 'test'. Do you need to install type definitions for a test runner?
Try npm i --save-dev @types/jest or npm i --save-dev @types/mocha.
I'm sure this is a typescript configuration issue but I have added the global types to the tsconfig file:
{
"compilerOptions": {
"types": ["vitest/globals"]
}
}
What do I need to do to get vs-code to recognise the globals?
typesfield of tsconfig for a properly configured npm dependency.tsconfig.json? Not something liketsconfig.test.jsontsconfig.test.jsontoo, but for your IDE to understand, it has to betsconfig.jsontsconfig.test.jsoninstead, but I can't find any way to do that. Changing thetsimporter.tsconfigNamesettings doesn't help.