✅ Builtin TypeChecking
In v0.25.0, Vitest allows you to write tests for your types, using expectTypeOf
or assertType
syntaxes. By default all tests inside *.test-d.ts
files are considered type tests. Run vitest typecheck
to run type tests.
// my.test-d.ts
import { assertType, expectTypeOf } from 'vitest'
import { mount } from './mount.js'
test('my types work properly', () => {
expectTypeOf(mount).toBeFunction()
expectTypeOf(mount).parameter(0).toMatchTypeOf<{ name: string }>()
// @ts-expect-error name is a string
assertType(mount({ name: 42 }))
})
Learn more at the documentation and this RFC
🚨 Breaking Changes
🚀 Features
onTestFailed
hook - by @antfu in #2210- Display error frame if present (like Vite) - by @haikyuu and @sheremet-va in #2257
- Benchmark table report - by @poyoho in #2179
- Add typechecking functionality - by @sheremet-va and @antfu in #2107
🐞 Bug Fixes
- Clear full screen only in watch mode - by @sheremet-va (c3d89)
- Don't serialize symbols and immutables - by @sheremet-va in #2266
- Use --conditions instead of -C - by @sheremet-va in #2267
- Show correct stack trace in errors and console - by @sheremet-va and @antfu in #2248
- Align
.each
behavior with jest - by @bartoszgolebiowski and @antfu in #2064 - Remove undefined values in options - by @g4rry420 and @antfu in #2281
- coverage: Istanbul provider to preserve implicit else - by @AriPerkkio in #2275