Vitest 1.0 is here! This release page lists all changes made to the project during the beta. For the migration guide, please refer to the documentation.
🚨 Breaking Changes
- Add support for
pool
andpoolOptions
, remove old flags - by @AriPerkkio in #4172 (114a9) - Support multiple parallel
child_process
- by @AriPerkkio in #3925 (8b4a4) - Make snapshots more visually pleasing by @sheremet-va in #3961
- Set
vitest
peer dependency range for sub packages - by @AriPerkkio in #4299 (cd03c) - Bump minimum node version to 18 and match Vite 5 requirement - by @ghiscoding in #4296 (263b7)
- Remove deprecated node loader - by @sheremet-va in #4371 (29299)
- Move browser providers to @vitest/browser package - by @sheremet-va in #4364 (5cdeb)
- Remove EnhancedSpy type, deprecate SpyInstance, improve mocks and vi documentation - by @sheremet-va and @dammy001 in #4400 (d40b3)
expect().toContain()
can handle classList, Node.contains, and any array-like structure. This means you cannot use it to check if one object is a subset of another - useexpect().toMatchObject()
in that case - by @sheremet-va in #4239 (ce84f)- runner: Correctly process custom tasks, update runner hooks naming by @sheremet-va in #4076
- coverage:
- glob based coverage thresholds by @AriPerkkio in #4442 (18300)
- Use
transformMode
and workspace project based source maps - by @AriPerkkio in #4309 (28109cc) - Enable
coverage.all
by default - by @AriPerkkio in #4265 (5a741)
🚀 Features
- Add Marko example and include code coverage for Marko files - by @DylanPiercey in #4263 (eac77)
- Update magic-string - by @bluwy in #4345 (fde18)
- Implement provide/inject API to transfer data from the main thread - by @sheremet-va in #4422 (a7522)
- Improve expectTypeOf error messages - by @mmkal, Misha Kaletsky and @sheremet-va in #4206 (18300)
- Add test.sequential() api - by @dsyddall in #4512 (c3619)
- Allow custom pools - by @sheremet-va in #4417 (a3fd5)
- Add --project option to limit what projects are running - by @sheremet-va, @dammy001 and @AriPerkkio in #4561 (58ef5)
- benchmark:
- browser:
- Support "none" provider and update lit example to use it - by @sheremet-va in #4427 (d03a2)
- coverage:
- Support
/* v8 ignore...
ignore hints - by @AriPerkkio in #4573 (f9e4a)
- Support
- expect:
- Support
expect.closeTo
api - by @Dunqing and golebiowskib in #4260 (7f91c) - Compare URL objects by href - by @kleinfreund and @AriPerkkio in #4615 (f7a73)
- Support
- snapshot:
- vite-node:
- vitest:
- Expose getBenchFn, getBenchOptions - by @sheremet-va in #4208 (8e5e4)
- Run typecheck during tests - by @sheremet-va in #4324 (a1aad)
- Filter stacktraces - by @clarkf in #1999 and #4338 (6b734)
- Expose execArgv to the different pools - by @adriencaccia in #4383 (9021e)
🐞 Bug Fixes
- Add multiple globals in VM+JSDOM - by @nstepien in #4199 and #4202 (fc947)
- Ignore "plugins" field in snapshotFormat option - by @sheremet-va in #4204 (db1ff)
nextTick
mocking error message to mention correct config option - by @AriPerkkio in #4215 (98fe3)- Export VitestUtils interface - by @fbritoferreira in #4301 (b1439)
- Assertion diff message handle non-writable sub-properties - by @bfamchon in #4278 (7e1a0)
- Don't bundle import from rollup - by @sheremet-va in #4392 (3b584)
- Support accessing fixture at same index of dependency fixture - by @dsyddall in #4387 (4cd1d)
- Make asynchronous fixtures work concurrently - by @dsyddall in #4403 (3c9f9)
- Coverage.100 crash when using as an cli argument - by @marcelobotega in #4346 (0db38)
- Support typechecking with Yarn PnP - by @sheremet-va in #4412 (1ecbe)
- Support accessing task from test context without accessing fixtures - by @dsyddall in #4419 (3397f)
- Copy custom asymmetric matchers to local
expect
- by @hi-ogawa in #4405 (9fe38) - Apply serializer to
Error
instance for thrown snapshot - by @hi-ogawa and @sheremet-va in #4396 (ac309) - Throw an error when running "vitest typecheck" - by @sheremet-va in #4439 (7f502)
- Don't expand snapshot diff by default - by @sheremet-va in #4430 (8983c)
- Handle errors thrown in fixtures - by @dsyddall (f6844)
- Default --open to !process.env.CI - by @collinstevens in #4477 (088a0)
- Disable ESBuild when user config disables it - by @Namchee in #4492 (9abde)
- Inherit concurrent/sequential in nested suites - by @dsyddall in #4482 (ca168)
- Provide customTesters to asymmetric matchers - by @sheremet-va (ac665)
- Apply
retry
andbail
from test config file - by @hi-ogawa in #4530 (94f9a) - Respect trailing slash when filtering by file path - by @ibuibu in #4538 (f377a)
- Date prototype when using setSystemTime - by @spiroka in #4584 (3f8c3)
- BrowserTestRunner called incorrect super methods - by @samthor in #4632 (8385c)
- Set process name for idle workers - by @AriPerkkio in #4641 (eca25)
- bench:
- browser:
- Improve error handling and don't rely on Node.js builtin modules in browser mode - by @sheremet-va in #4244 (e7e8c)
- Disable hijacking ES modules until vi.mock is implemented - by @sheremet-va in #4414 (ab556)
- Add vitest/ imports to entries - by @sheremet-va in #4514 (648bc)
- Wait until vite finishes prebundling of vitest dependencies - by @sheremet-va in #4518 (56ee7)
- Allow for
pretty-format
as a sibling dependency - by @nicojs in #4590 (ed50a) - Don't go into an infinite reload loop, don't fail if "error" event is caught - by @sheremet-va in #4618 (ec3d6)
- Respect "server" option in vite config - by @sheremet-va in #4627 (723f6)
- cli:
- Do not capture
stdin
when in run mode - by @AriPerkkio in #4310 (fc51a)
- Do not capture
- config:
- Type issue of
pool
andpoolMatchGlobs
in defineConfig - by @InfiniteXyy in #4282 (9112c)
- Type issue of
- coverage:
thresholdAutoUpdate
to detect zero limits - by @AriPerkkio in #4287 (a29fe)- Exclude files and directories starting with dot by default - by @AriPerkkio in #4428 (b3327)
- Improve memory usage by writing temporary files on file system - by @AriPerkkio in #4603 (4166c)
- deps:
- example:
- expect:
- Publish types file - by @sheremet-va (5996c)
Object.freeze
breakstoEqual
- by @Dunqing in #4303 (a4501)- Publish semantically correct chai types - by @sheremet-va in #4322 (80a70)
- Print full error if promise is rejected - by @sheremet-va in #4467 (cadb9)
- Don't fail when using jest expect - by @sheremet-va in #4517 (60d6d)
- happy-dom:
- Don't crash when calling useFakeTimers with empty config - by @sheremet-va in #4214 (2e1a1)
- jsdom:
- Don't go into an infinite recusion when calling atob - by @sheremet-va (da794)
- runner:
- Fixture needs to be initialized for each test - by @Dunqing in #4250 (76a93)
- Nested tests should throw errors - by @Dunqing in #4262 (8ac9f)
- Removes deprecated
error
option from TaskResult - by @Dunqing in #4313 (4cee6) - Preserve fixtures when calling runif and skipif - by @dsyddall in #4585 and #4591 (515ea)
- PassWithNoTests option not work - by @Dunqing in #4553 (8d183)
- vite-node:
- vitest:
- Make @types/node optional - by @sheremet-va in #4210 (a5383)
- Inline chai types instead of using @types/chai - by @sheremet-va in #4209 (5f477)
- Don't initialize globalSetup if workspace doesn't run tests - by @sheremet-va in #4213 (06461)
- Deduplicate vitest when running globally or in a workspace - by @sheremet-va in #4238 (93504)
- Print file path instead of "unknown test" when logging - by @Dunqing in #4146 (ec2e8)
- Failed to load custom environment from js/ts file - by @Dunqing and @sheremet-va in #4255 (da8d0)
- Support assets in new URL in Vite 5 - by @sheremet-va in #4258 (d280f)
- Correctly hoist
vi.hoisted
if assigned - by @sheremet-va in #4285 (ff93a) - Run globalSetup from the root config even if it's not in a workspace - by @sheremet-va in #4325 (4293e)
- Pass correct mode in vitest config function - by @adriencaccia in #4399 (b8ca3)
- Throw an error if vitest is imported using require() - by @sheremet-va in #4466 (e5cf1)
- Use correct type for defineProject to allow usage in mergeConfig - by @sheremet-va in #4498 (7dee8)
- Throw an error if Vite wasn't able to resolve aliased path - by @sheremet-va in #4503 (50333)
- Improve vi.waitUntil type to excude falsy types - by @sheremet-va in #4572 (23652)
- Add import-meta.d.ts - by @macdaddyaz in #4571 (dd802)
- Correctly support CSS variable when using happy-dom - by @sheremet-va in #4601 (9fbf3)
- Pass correct server options in workspace - by @hironytic in #4539 and #4540 (241a8)
- Independently mock each instance's methods for mocked class - by @hi-ogawa in #4564 (05b05)
- vm:
- Remove sequencer usage from createVmThreadsPool function - by @mhogeveen in #4638 (54d52)
🏎 Performance
- Update
log-update
v9 - by @AriPerkkio in #4390 (ba1df) - Close pool early in run-mode - by @AriPerkkio in #4623 (e0e20)
- coverage-istanbul:
all: true
instruments already instrumented files - by @AriPerkkio in #4552 (d1e1b)