4.1.0
Vitest 4.1 is out!
This release page lists all changes made to the project during the 4.1 beta. To get a review of all the new features, read our blog post.
🚀 Features
- Return a disposable from doMock() - by @kirkwaiblinger in https://github.com/vitest-dev/vitest/issues/9332 (e3e65)
- Added chai style assertions - by @ronnakamoto and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8842 (841df)
- Update to sinon/fake-timers v15 and add
setTickModeto timer controls - by @atscott and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8726 (4b480) - Expose matcher types - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9448 (3e4b9)
- Add
toTestSpecificationto reported tasks - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9464 (1a470) - Show a warning if
vi.mockorvi.hoistedare declared outside of top level of the module - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9387 (5db54) - Track and display expectedly failed tests (.fails) in UI and CLI - by @Copilot, sheremet-va and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9476 (77d75)
- Support tags - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9478 (de7c8)
- Implement
aroundEachandaroundAllhooks - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9450 (2a8cb) - Stabilize experimental features - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9529 (b5fd2)
- Accept
neworallin--updateflag - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9543 (a5acf) - Support
metain test options - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9535 (7d622) - Support type inference with a new
test.extendsyntax - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9550 (e5385) - Support vite 8 beta, fix type issues in the config with different vite versions - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9587 (99028)
- Add assertion helper to hide internal stack traces - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9594 (eeb0a)
- Store failure screenshots using artifacts API - by @macarie in https://github.com/vitest-dev/vitest/issues/9588 (24603)
- Allow
vitest listto statically collect tests instead of running files to collect them - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9630 (7a8e7) - Add
--detect-async-leaks- by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9528 (c594d) - Implement
mockThrowandmockThrowOnce- by @thor-juhasz and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9512 (61917) - Support
update: "none"and add docs about snapshots behavior on CI - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9700 (05f18) - Support playwright
launchOptionswithconnectOptions- by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9702 (f0ff1) - Add
page/locator.markAPI to enhance playwright trace - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9652 (d0ee5) - api:
- Support tests starting or ending with
testinexperimental_parseSpecification- by @jgillick and Jeremy Gillick in https://github.com/vitest-dev/vitest/issues/9235 (2f367) - Add filters to
createSpecification- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9336 (c8e6c) - Expose
runTestFilesas alternative torunTestSpecifications- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9443 (43d76) - Add
allowWriteandallowExecoptions toapi- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9350 (20e00) - Allow passing down test cases to
toTestSpecification- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9627 (6f17d)
- Support tests starting or ending with
- browser:
- Add
userEvent.wheelAPI - by @macarie in https://github.com/vitest-dev/vitest/issues/9188 (66080) - Add
filterNodeoption to prettyDOM for filtering browser assertion error output - by @Copilot, sheremet-va and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9475 (d3220) - Support playwright persistent context - by @hi-ogawa, Claude Opus 4.6 and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9229 (f865d)
- Added
detailsPanelPositionoption and button - by @shairez in https://github.com/vitest-dev/vitest/issues/9525 (c8a31) - Use BlazeDiff instead of pixelmatch - by @macarie in https://github.com/vitest-dev/vitest/issues/9514 (30936)
- Add
findElementand enable strict mode in webdriverio and preview - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9677 (c3f37)
- Add
- cli:
- Add @bomb.sh/tab completions - by @AmirSa12 and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8639 (200f3)
- coverage:
- Support
ignore start/stopignore hints - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9204 (e59c9) - Add
coverage.changedoption to report only changed files - by @kykim00 and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9521 (1d939)
- Support
- experimental:
- Add
onModuleRunnerhook toworker.init- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9286 (e977f) - Option to disable the module runner - by @sheremet-va and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9210 (9be61)
- Add
importDurations: { limit, print }options - by @hi-ogawa, Claude Opus 4.6 and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9401 (7e10f) - Add print and fail thresholds for
importDurations- by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9533 (3f7a5)
- Add
- fixtures:
- Pass down file context to
beforeAll/afterAll- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9572 (c8339)
- Pass down file context to
- reporters:
- Add
agentreporter to reduce ai agent token usage - by @cpojer in https://github.com/vitest-dev/vitest/issues/9779 (3e9e0)
- Add
- runner:
- Enhance
retryoptions - by @MazenSamehR, Matan Shavit, @AriPerkkio and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9370 (9e4cf)
- Enhance
- ui:
- Allow run individual test/suites - by @userquin in https://github.com/vitest-dev/vitest/issues/9465 (73b10)
- Add project filter/sort support - by @userquin in https://github.com/vitest-dev/vitest/issues/8689 (0c7ea)
- Add duration sorting to explorer - by @julianhahn and @cursoragent in https://github.com/vitest-dev/vitest/issues/9603 (209b1)
- Implement filter for slow tests - by @DerYeger and @userquin in https://github.com/vitest-dev/vitest/issues/9705 (8880c)
- vitest:
- Add run summary in GitHub Actions Reporter - by @macarie and jhnance in https://github.com/vitest-dev/vitest/issues/9579 (96bfc)
🐞 Bug Fixes
- Deprecate several vitest/* entry points - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9347 (fd459)
- Use
meta.urlincreateRequire- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9441 (e3422) - Preact browser mode init example of render function not async - by @WuMingDao in https://github.com/vitest-dev/vitest/issues/9375 (2bea5)
- Deprecate unused types in matcher context - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9449 (20f87)
- Handle
external/noExternalduringconfigEnvironmenthook - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9508 (59ea2) - Replace default ssr environment runner with Vitest server module runner - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9506 (cd5db)
- Propagate experimental CLI options to child projects - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9531 (b624f)
- Show a warning when
browser.isolateis used - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9410 (3d48e) - Fix
vi.mock({ spy: true })node v8 coverage - by @hi-ogawa, hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9541 (687b6) - Don't show internal ssr handler in errors - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9547 (76c43)
- Close vitest if it failed to start - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9573 (728ba)
- Fix ssr environment runner in project - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9584 (09006)
- Trim trailing white spaces in code block - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9591 (f78be)
- Support inline snapshot inside test.for/each - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9590 (615fd)
- Apply source maps for external module stack trace - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9152 (79e20)
- Remove the
.namefrom statically collected test - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9596 (b66ff) - Don't suppress warnings on pnp - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9602 (89cbd)
- Support snapshot with
expect.soft- by @iumehara, @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9231 (3eb2c) - Log seed when only
sequence.shuffle.testsis enabled - by @kaigritun, Kai Gritun and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9576 (8182b) - Externalize
expect/src/utilsfromvitest- by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9616 (48739) - Ignore test.override during static collection - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9620 (09174)
- Increase stacktrace limit for
--detect-async-leaks- by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9638 (9fd4c) - Hanging-reporter link in cli - by @flx-sta in https://github.com/vitest-dev/vitest/issues/9649 (7c103)
- Fix teardown timeout of
aroundEach/Allwhen inneraroundEach/Allthrows - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9657 (4ec6c) - Fix ui mode / html reporter and coverage integration - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9626 (86fad)
- Don't continue when
aroundEach/Allsetup timed out - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9670 (bb013) - Align
VitestRunnerConfigoptional fields withSerializedConfig- by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9661 (79520) - Handle Symbol values in format utility - by @nami8824 in https://github.com/vitest-dev/vitest/issues/9658 (0583f)
- Deprecate
toBe*spy assertions in favor oftoHaveBeen*(andtoThrowError) - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9665 (4d390) - Don't propagate nested
aroundEach/Allerrors but aggregate them on runner - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9673 (b6365) - Show a better error if there is a pending dynamic import - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9676 (7ef5c)
- Preserve stack trace of
resolves/rejectschained assertion error - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9679 (c6151) - Handle module-sync condition in vmThreads/vmForks require - by @lesleh in https://github.com/vitest-dev/vitest/issues/9650 and https://github.com/vitest-dev/vitest/issues/9651 (bb203)
- Hooks should respect
maxConcurrency- by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9653 (16d13) - Recursively autospy module object - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9687 (695a8)
- Remove trailing spaces from diff error log - by @hi-ogawa and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9680 (395d1)
- Respect project
resolve.conditionsfor externals - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9717 (1d498) - Use object for WeakMap instead of a symbol to support webcontainers - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9731 (c5225)
- Fix re-mocking virtual module - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9748 (3cbbb)
- Cancelling should stop current test immediately - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9729 (0cb2f)
- Make
mockObjectchange backwards compatible - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9744 (84c69) - Fix
URL.nameon jsdom - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9767 (031f3) - Save and restore module graph in blob reporter - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9740 (84355)
- Don't silence reporter errors from test runtime events handler in normal run and --merge-reports - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9727 (4072d)
- Fix
vi.importActual()for virtual modules - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9772 (1e89e) - Throw
FixtureAccessErrorif suite hook accesses undefined fixture - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9786 (fc2ce) - Allow hyphens in project config file name pattern - by @Koutaro-Hanabusa and @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9760 (33e96)
- Manual and redirect mock shouldn't
loadortransformoriginal module - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9774 (a8216) hideSkippedTestsshould not hidetest.todo- by @oilater in https://github.com/vitest-dev/vitest/issues/9562 and https://github.com/vitest-dev/vitest/issues/9781 (8181e)- Allow catch/finally for async assertion - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9827 (031f0)
- Resolve fixture overrides from test's suite in
beforeEachhooks - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9826 (99e52) - Use isAgent check, not just TTY, for watch mode - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9841 (c3cac)
- Use
performance.nowto measure test timeout duration - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9795 (f48a6) - Correctly identify concurrent test during static analysis - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9846 (1de0a)
- browser:
- Avoid updating screenshots when
toMatchScreenshotpasses - by @macarie in https://github.com/vitest-dev/vitest/issues/9289 (46aab) - Hide injected data-testid attributes - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9503 (c8d2c)
- Throw an error if iframe was reloaded - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9516 (73a81)
- Encode projectName in browser client URL - by @dkkim0122 in https://github.com/vitest-dev/vitest/issues/9523 (5b164)
- Don't take failure screenshot if tests have artifacts created by
toMatchScreenshot- by @macarie in https://github.com/vitest-dev/vitest/issues/9552 (83ca0) - Remove
--remote-debugging-addressfrom chrome args - by @hi-ogawa and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9712 (f09bb) - Make sure userEvent actions support
ensureAwaited- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9732 (97685) - Types of
getCDPSessionandcdp()- by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9716 (689a2) - Skip esbuild.legalComments when using rolldown-vite - by @Copilot, hi-ogawa and @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9803 (3505f)
- Avoid updating screenshots when
- chai:
- Don't allow
deepEqualin the config because it's not serializable - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9666 (9ee99)
- Don't allow
- coverage:
- Infer transform mode for uncovered files - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9435 (f3967)
thresholds.autoUpdateto preserve ending whitespace - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9436 (7e534)
- deps:
- Update all non-major dependencies - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/9192 (90c30)
- Update all non-major dependencies - in https://github.com/vitest-dev/vitest/issues/9485 (c0118)
- Update all non-major dependencies - in https://github.com/vitest-dev/vitest/issues/9567 (13c9e)
- docs:
- Fix old
/config/#optionhash links causing hydration errors - by @hi-ogawa, Claude Opus 4.6 and @sheremet-va in https://github.com/vitest-dev/vitest/issues/9610 (a603c)
- Fix old
- expect:
toMatchObject(Map/Set)should expectMap/Seton left hand side - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9532 (381da)- Fix objectContaining with proxy - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9554 (7ce34)
- Support arbitrary value equality for
toThrowand make Error detection robust - by @hi-ogawa and Claude Opus 4.6 in https://github.com/vitest-dev/vitest/issues/9570 (de215)
- mock:
- Inject helpers after hashbang if present - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9545 (65432)
- mocker:
- Update vite's peer dependency range - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9808 (36f9a)
- reporter:
dotreporter leaves pending tests - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9684 (4d793)
- runner:
- Mark repeated tests as finished on last run - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/9707 (cc735)
- spy:
- Support deep partial in vi.mocked - by @j2h30728 in https://github.com/vitest-dev/vitest/issues/8152 and https://github.com/vitest-dev/vitest/issues/9493 (71cb5)
- Fallback to object accessor if descriptor's value is
undefined- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9511 (6f181) - Throw correct errors when shorthand methods are used on a class - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9513 (5d0fd)
- types:
bench.reportersno longer gives type errors when passing file name string paths - by @Bertie690 in https://github.com/vitest-dev/vitest/issues/9695 (093c8)
- ui:
- Process artifact attachments when generating HTML reporter - by @macarie in https://github.com/vitest-dev/vitest/issues/9472 (96eb9)
- Don't fail if --ui and --root are specified together - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9536 (d9305)
🏎 Performance
- pretty-format: Combine DOMElement plugins - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/9581 (da85a)