What’s New

Vitest

Developer Tools

A Vite-native testing framework.

Latest v4.1.10 · by VoidZeroWebsitevitest-dev/vitest

Changelog

v5.0.0-beta.7

Pre-release
Added
  • Add toggable injectCjsGlobals option
  • Promote fsModuleCache to a top-level option
  • Support non-ascii characters in for/each title placeholders
  • Add pluggable benchmark provider API
Changed
  • Separate config resolution from the server creation
  • Serve warm modules to workers in one round-trip and enable the node compile cache
  • Make the Node compile cache opt-in and persist worker caches on teardown
  • Reuse compiled code across vm pool contexts and prewarm the module graph
Fixed
  • Disable server HMR before plugins read it in their config hook
  • Close the pool before the Vite servers
  • Remove listeners in the typecheck worker's off
  • Keep per-file isolation in vm pools when maxWorkers is 1
  • Prevent node builtins double prefix
  • Set non-zero exit code when teardown throws during close
  • Don't race the typechecker spawn grace period on windows
  • Preserve pre-transform request defaults in browser
  • Fix error stacktrace location off-by-one in browser
  • Inlined awaited import should not trigger syntax error after transform in browser
  • Mock window.print to avoid hanging in browser
  • Vm pools to respect cgroupsv2 memory limit in pool
   🚨 Breaking Changes
   🚀 Features
   🐞 Bug Fixes
   🏎 Performance
    View changes on GitHub

v5.0.0-beta.6

Pre-release
Added
  • Create vi.when() for conditional mocking
Changed
  • Add screenshotDirectory config to browser.expect.toMatchScreenshot
  • Update @sinonjs/fake-timers and support mocking Temporal
  • Write json and junit reporter output files to .vitest by default
  • Change html reporter default output to .vitest
  • Harden UI API access
Fixed
  • Fix setImmediate await in detect-async-leak
  • Fix per-project sequence config
  • Add handshake timeout to iframe communication
  • Don't print column in test names when includeTaskLocation is enabled
  • Always derive a positive locator action timeout in browser
  • Resize the browser ui only if it's not headless
  • Check fs access in builtin commands
  • Fix non-awaited module imports causing wrong offsets in coverage
  • Fail fast when coverage.reportsDirectory conflicts between concurrent runs
  • Improve error message when worker exits unexpectedly
  • Allow changed in configuration options
  • Fix external module resolve error with deps optimizer query for encoded URI
Removed
  • Remove webdriverio package
  • Clear mocks by default before each test
   🚨 Breaking Changes
   🚀 Features
   🐞 Bug Fixes
    View changes on GitHub

v4.1.10

Fixed
  • Check fs access in builtin commands for browser
  • Fix external module resolve error with deps optimizer query for encoded URI in vm
   🐞 Bug Fixes
    View changes on GitHub

v4.1.9

Fixed
  • Fix importOriginal with optimizer and query import
  • Wait for orchestrator readiness before resolving browser sessions
  • Wait for iframe tester readiness before preparing
  • Hoist vi.mock() for vite-plus/test imports
  • Prevent test run hang on worker crash
🐞 Bug Fixes
View changes on GitHub

v5.0.0-beta.5

Pre-release
Added
  • Display nested mark trace in UI in browser mode
  • Add --repeats CLI option
  • Allow thresholds.autoUpdate to receive previous threshold as argument in coverage
Changed
  • Allow mutating happy-dom/jsdom window object
  • Expose concurrencyId/workerId on TestModule's diagnostics, make id 1-based
  • Require sessionId for orchestrator html request in browser mode
  • Allow thresholds.perFile to accept an object in coverage
Fixed
  • Fix mixed stdout/stderr log timestamps in onUserConsoleLog
  • Fix importOriginal with optimizer and query import
  • Correct transform time calculation in merged report
  • Wait for orchestrator readiness before resolving browser sessions
  • Wait for iframe tester readiness before preparing
  • Encode iframeId in tester iframe URL
  • Avoid matching sibling project roots in coverage
  • Hoist vi.mock() for vite-plus/test imports
  • Prevent test run hang on worker crash
  • Strip non-serializable functions from inline diff config
Removed
  • Don't lookup config file from ancestor directories
  • Inline @vitest/runner package, do not publish it anymore
   🚨 Breaking Changes
   🚀 Features
   🐞 Bug Fixes
    View changes on GitHub

v5.0.0-beta.4

Pre-release
Added
  • Show trace view steps in editor panel in browser mode
  • Support html reporter single file output
Changed
  • toHaveTextContent is strict, add toMatchTextContent as alternative
  • Rewrite the benchmark public API
  • Enable locators.exact by default in browser mode
  • Improve performance in hot paths
Fixed
  • Preserve vi.defineHelper callsite for async error stack
  • Respect disableConsoleIntercept in browser mode
  • ForceRerunTriggers uses directory globs against files
  • Unify typechecking and ast collection
  • Don't print typecheck warning more than once
  • Correct column when parsing tests
  • Fix stale source map on watch mode in browser
  • Escape inline orchestrator scripts in browser
  • Disable client CDP API when allowWrite/allowExec: false in browser
  • Skip hoist transform without ast mock calls in mocker
  • Fix module graph in browser mode with --ui
  • Render ANSI color codes in editor panel inline error widget in UI
  • Allow gpu in headless chrome in webdriverio
Removed
  • Throw an error if hoistable methods are outside the top level scope
   🚨 Breaking Changes
   🚀 Features
   🐞 Bug Fixes
   🏎 Performance
    View changes on GitHub

v3.2.5

Added
  • Add `allowWrite` and `allowExec` options to api
Fixed
  • Disable client `cdp` API when `allowWrite/allowExec: false`
   🚀 Features
   🐞 Bug Fixes
    View changes on GitHub

v4.1.8

Fixed
  • Disable client cdp API when allowWrite/allowExec: false in browser
  • Remove orphaned Playwright route when same module is mocked via multiple ids
   🐞 Bug Fixes
    View changes on GitHub