Reputation: 5159
I'm trying the in-source testing of vitest. Here is the example given by the doc:
if (import.meta.vitest) {
const { it, expect } = import.meta.vitest;
it('add', () => {
expect(1 + 1).toBe(2);
});
}
But I get the red squiggles Property 'vitest' does not exist on type 'ImportMeta'
in VSCode. How can I fix it?
Upvotes: 5
Views: 2964
Reputation: 106
// tsconfig.json
{"compilerOptions": {"types": ["vitest/importMeta"]}}
You can see the doc https://vitest.dev/guide/in-source.html#typescript
Upvotes: 9