4.0.0
Vitest 4.0 is out!
To stay updated, read our blog post and check the migration guide.
🚨 Breaking Changes
- Remove
'basic'reporter - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/7884 (82fcf) - Simplify default exclude pattern - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/6287 (14c50)
- Remove deprecated getSourceMap - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8194 (ff934)
- Replace deprecated ErrorWithDiff with TestError - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8195 (da59e)
- Remove UserConfig type in favor of ViteUserConfig - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8196 (22f7f)
- Remove deprecated coverage options in favor of
vitest/nodeexports - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8197 (dc848) - Remove deprecated internal helpers and environment exports - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8198 (4703c)
- Remove deprecated typecheck and runner types - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8199 (89a1c)
- Remove Node types from the main entry point, use
vitest/nodeinstead - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8200 (1e60c) - Remove support for Vite 5 - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8202 (cb8b0)
- Remove deprecated types - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8203 (66bee)
- Remove deprecated environmentMatchGlobs and poolMatchGlobs - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8205 (be11d)
- Remove deprecated
workspaceoption in favor ofprojects- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8218 (76fb7) - Ignore
--standalonewhen CLI filename filter is used - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8262 (013bf) - Use module-runner instead of vite-node - by @sheremet-va and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8208 (9be01)
- Rewrite spying implementation to make module mocking more intuitive - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8363 (9e412)
- Remove deprecated APIs - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8428 (a1cb9)
- Remove
minWorkersand set it automatically to 0 in non watch mode - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8454 (2c2d1) - Verbose reporter prints tests in a list, introduce
treereporter - by @sheremet-va and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8500 (25fd3) - Include shadow root contents in pretty-format output - by @wkillerud in https://github.com/vitest-dev/vitest/issues/8545 (9e722)
- Remove deprecated order from test() API - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8594 (4d419)
- Rewrite pools without
tinypool- by @AriPerkkio and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8705 (4822d) - browser: Require a provider factory instead of a string - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8445 (606cb)
- expect: Pass current equality testers to asymmetric matcher - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/6825 (965ce)
- projects: Allow only files that have "vitest.config" or "vite.config" in the name - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8542 (304bc)
- reporter: Remove deprecated APIs - by @AriPerkkio and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8223 (149f8)
- runner: Set mode to
todoif no function is passed down totestordescribe- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8346 (1a81c) - snapshot: Fail test with obsolete snapshot on CI - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/7963 (4d84f)
- spy: Support spying on classes - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/6160 (abc0d)
🚀 Features
- Provide entity to onConsoleLog - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8159 (437d4)
- Add
onUnhandledErrorcallback - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8162 (924cb) - Add spy option to vi.mockObject - by @rChaoz in https://github.com/vitest-dev/vitest/issues/8285 (81d76)
- Don't use vite-node in coverage packages - by @sheremet-va (ffdb4)
- Clickable dashboard numbers - by @shairez in https://github.com/vitest-dev/vitest/issues/7406 (2344c)
- Display test "path" when filtering - by @userquin in https://github.com/vitest-dev/vitest/issues/8547 (2e491)
- Introduce separate packages for browser mode providers - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8629 (0dc93)
- Add hooks with type-safe extra context to TestAPI - by @ysfaran in https://github.com/vitest-dev/vitest/issues/8623 (6b21c)
- Support
expect.assertfor type narrowing - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8695 (fe589) - Add
displayAnnotationsoption togithub-options- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8706 (4a66d) - Add schema validation matchers - by @zirkelc in https://github.com/vitest-dev/vitest/issues/8527 (c0b25)
- Add a way to dump transformed content - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8711 (931c0)
- api:
- Expose
experimental_parseSpecifications- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8408 (fdeb2) - Expose Vitest watcher - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8413 (aaa6e)
- Add
enableCoverageanddisableCoveragemethods - by @sheremet-va and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8412 (61eb7) - Add
getGlobalTestNamePatternmethod - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8438 (bdb70) - Add
relativeModuleIdtoTestModule- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8505 (3be09) - Add
getSeedmethod - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8592 (438c4)
- Expose
- browser:
- Support
toBeInViewportutility method to assert element is in viewport or not - by @Shinyaigeek in https://github.com/vitest-dev/vitest/issues/8234 (ceed5) - Add qwik to the
vitest initcli command - by @thejackshelton in https://github.com/vitest-dev/vitest/issues/8330 (1638b) - Introduce
toMatchScreenshotfor Visual Regression Testing - by @macarie in https://github.com/vitest-dev/vitest/issues/8041 (d45f9) - Add
trackUnhandledErrorsoption - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8386 (c0ec0) - Support iframe locator with playwright provider - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8016 (57b2c)
- Add
lengthproperty to locators,toHaveLengthnow accepts locators - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8512 (2308c) - Support playwright tracing - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8584 (1aac5)
- Expose
optionsonBrowserProviderOption- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8609 (0d0e5) - Support
--inspectoption in webdriverio - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8613 (38adc) - Support custom screenshot comparison algorithms - by @macarie in https://github.com/vitest-dev/vitest/issues/8687 (e63b1)
- Support
- coverage:
autoUpdateto support percentage formatting - by @Battjmo and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8456 (99e01)
- expect:
- Support
toBeNullableexpect function to check provided value is nullish - by @Shinyaigeek and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8294 (eeec5)
- Support
- mocker:
- Add
automockerentry - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8301 (e9c92)
- Add
🐞 Bug Fixes
- Allow overriding globals in types - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8215 (2248b)
- Remove unused dependencies - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8184 (feadc)
- Distribute test files to shards more evenly - by @Shinyaigeek and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8288 (7b489)
- Use suite's timeout when
test.extend- by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8278 (43977) - Support snapshot with no object key sorting - by @hi-ogawa and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8136 (e85e3)
- Annotation location always points to the test file - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8315 (88071)
- Add
--changedflag support tovitest listcommand - by @haakonjackfloat in https://github.com/vitest-dev/vitest/issues/8270 and https://github.com/vitest-dev/vitest/issues/8272 (e71a5) - Prevent rpc timeout on slow thread blocking synchronous methods - by @AriPerkkio and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8297 (bea87)
- Forbid setting environment to
browser- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8334 (0417a) - Invalidate modules in all module graphs when the file is changed - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8352 (94ab3)
- Screenshot masks with Playwright provider - by @macarie in https://github.com/vitest-dev/vitest/issues/8357 (459ef)
- Configure
oxcinstead ofesbuildonrolldown-vite- by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/8378 (e922e) - Make sure test errors always have
stacksproperty in Node.js context - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8392 (b825e) - Support
import.meta.resolveon Vite 7 - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/8493 (549d3) - Show the assertion error first when
expect.pollassertion fails - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8483 (fb450) - Override fake timers when
useFakeTimersis called multiple times - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8504 (ed7e3) - Custom expect messages for
expect.extendmatchers - by @lzl0304 in https://github.com/vitest-dev/vitest/issues/8520 (96945) - Process sourcemaps for stack traces from
globalSetupfiles - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8534 (8978a) - Resolve performance issue when throwing errors with stackTraceLimit = 0 - by @Copilot, sheremet-va and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8531 (6d5b5)
- Avoid recursively applying
$and%formatting totest.for/eachtitle - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/8557 (ea6d7) - Replace wildcard exports
"./*"with specific files in vitest package - by @hi-ogawa in https://github.com/vitest-dev/vitest/issues/8560 (ce746) - Don't publish unused d.ts files - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8562 (42dfd)
- Remove loupe dependencies from
optimizeDeps.includefor browser mode - by @jake-danton in https://github.com/vitest-dev/vitest/issues/8570 (cdcf7) - Update
enginesfield to drop Node 18 support - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8608 (9a0bf) - Correctly inherit test options on extended tests - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8618 (15c09)
- Update @types/node peer deps - by @sheremet-va (ee6b2)
- Re-export CDP Session directly from playwright - by @mrginglymus in https://github.com/vitest-dev/vitest/issues/8702 (9553a)
- Disable trackUnhandledErrors if inspector is enabled - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8732 (acac7)
baseoption doesn't crash vitest - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8760 (9f0ec)- browser:
- Run in-source tests only when the file itsels is a test file - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8204 (bdd2e)
locator.element()returnsHTMLElementorSVGElement- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8440 (c1ac1)- Don't import from
vitedirectly - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8541 (d7fca) - Update expect.element type to match the implementation - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8597 (b2804)
- Throw an error if iframe is not accessible anymore - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8601 (6acdc)
- Stop creating unnecessary directories when taking screenshots - by @macarie in https://github.com/vitest-dev/vitest/issues/8605 (b1c8f)
- Always define commands - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8626 (acbe0)
- Exclude deprecated context import from optimization - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8658 (a96ea)
- Allow importing BrowserCommand if no browser package is installed - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8666 (95c36)
- Define an export for browser/utils - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8678 (529ab)
- Allow service workers to mock the network in chromium without breaking vi.mock - by @Georgegriff and @sheremet-va in https://github.com/vitest-dev/vitest/issues/8668 (87108)
- Support sync
not.toBeInTheDocument()- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8751 (f5d06)
- core:
- Fix
objectContainingexpect utility to have more compatibility to jest's one - by @Shinyaigeek in https://github.com/vitest-dev/vitest/issues/8241 (480be)
- Fix
- coverage:
- Include files based on
--projectfilter - by @gtbuchanan in https://github.com/vitest-dev/vitest/issues/7885 (761be) - Prevent encoding filenames of uncovered files - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8239 (8a998)
- Handle query param based transforms correctly - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8418 (a400a)
- Enforce order of
vitest:coverage-transformplugin - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8477 (ff517) - V8 to ignore Vite's generated cjs import helpers - by @mrginglymus and @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8718 (35816)
- Keep only strings in
coverage.exclude- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8731 (c9c30)
- Include files based on
- deps:
- Update all non-major dependencies - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8235 (a1e57)
- Update all non-major dependencies - in https://github.com/vitest-dev/vitest/issues/8328 (aa79e)
- Update all non-major dependencies - in https://github.com/vitest-dev/vitest/issues/8348 (13f94)
- Update all non-major dependencies - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8382 (704eb)
- Update all non-major dependencies - in https://github.com/vitest-dev/vitest/issues/8550 (048f7)
- jsdom:
- Override globals that Fetch API relies on - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8390 (05b41)
- Support AbortSignal API - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8704 (f6690)
- mocker:
- Fix
regexpHoistableto allow whitespace before parentheses - by @cszhjh in https://github.com/vitest-dev/vitest/issues/8231 (a0f9a)
- Fix
- module-runner:
- Resolve
resolvedSourcescorrectly - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8736 (8fc52) - Support getBuiltins - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8746 (87bb8)
- Resolve
- pool:
- Properly reuse the vm pool - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8758 (08498)
- reporter:
- Invisible CLI menus when
vitest --standalone- by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8248 (37cc2)
- Invisible CLI menus when
- rolldown-vite:
- Properly disable minifier in the browser client - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8306 (f55bb)
- runner:
- Don't bundle runner with utils - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8496 (2b4b0)
- spy:
- Fix spyOn types with optional method - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8499 (d3afa)
- Can respy on an exported method - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8521 (bf450)
- Don't fail when spying on static getters - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8589 (ac1d9)
- types:
- Ensure Chai declaration merge works with TS-Go - by @LukeAbby in https://github.com/vitest-dev/vitest/issues/8188 (5261d)
- Allow returning a promise from defineConfig - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8651 (c3474)
- ui:
- Keep the same tab open when clicking on different tests - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8599 (3e535)
- utils:
- Remove ast export - by @bluwy in https://github.com/vitest-dev/vitest/issues/8435 (21622)
- vitest:
- Override
config.includeoption withconfig.browser.instances[].includeoption if it is specified - by @Shinyaigeek in https://github.com/vitest-dev/vitest/issues/8260 (010fc)
- Override
- watch:
- Filename filter runs duplicate tests in workspaces - by @AriPerkkio in https://github.com/vitest-dev/vitest/issues/8250 (932d8)
- wdio:
- Wait for the driver to be properly closed - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8305 (c16ab)
- Properly construct the shadow root selector if there are multiple elements - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8354 (28765)
🏎 Performance
- Avoid spawning extra workers if no tests will run there - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8446 (3fb3e)
- Don't set
process.title- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8453 (0a766) - Remove chai as a direct dependency, keep it in
@vitest/expect- by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8461 (cc98c) - Reduce the amount of dynamic imports - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8465 (db6cd)
- Use ES2022 language features - by @TrevorBurnham in https://github.com/vitest-dev/vitest/issues/8492 (bb34c)
- Delay populating node-globals - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8506 (41cbc)
- Get
workerIdfrom a global object - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/8507 (46b13) - Replace startsWith with strict equality - by @btea in https://github.com/vitest-dev/vitest/issues/8546 (c42e6)
- Reduce the number of unused imports - by @sheremet-va in
These notes run past the length kept in the archive. The rest is on the publisher’s page.