This package allows you to use import { expect, test, ... } from "vitest"
statements in your ts test files without needing to add vitest
to your dependencies
or devDependencies
lists.
Supported versions:
- vitest 2.x
- vitest 3.x
Note
Vitest Node APIs are not included in this package. You will still need to install vitest
to use them. For example:
vitest/node
vitest/config
pnpm/yarn/npm add --save-dev vitest-types
Then add vitest-types/2
to compilerOptions.types
list in the tsconfig.json
. For example:
{
"compilerOptions": {
"types": ["vitest-types/2"]
}
}
Then add vitest-types/3
to compilerOptions.types
list in the tsconfig.json
. For example:
{
"compilerOptions": {
"types": ["vitest-types/3"]
}
}
Now you can use import { expect, test, ... } from "vitest"
in your test files.
// a.test.ts
import { expect, test } from "vitest";
test('foo', () => {
expect(1).toBe(1);
})
When you're running vitest with apis global injection(--globals
), you should also add vitest-types/2/globals
/vitest-types/3/globals
to the compilerOptions.types
list. For example:
{
"compilerOptions": {
"types": ["vitest-types/2/globals"]
}
}
// a.test.ts
test('foo', () => {
expect(1).toBe(1);
})