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?
types
field of tsconfig for a properly configured npm dependency. – Adamectsconfig.json
? Not something liketsconfig.test.json
– Pyoidtsconfig.test.json
too, but for your IDE to understand, it has to betsconfig.json
– Pyoid