Releases: vitest-dev/vitest
Releases · vitest-dev/vitest
v2.0.0
Vitest 2.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
- Simplify mock function generic types and align with jest - by @hi-ogawa in #4784 (a0c1d37)
- Remove
--segfault-retry
- by @sheremet-va in #5514 (ed60e)- This flag was introduced to combat
threads
segfaults. Our current recommendation is to use the new defaultforks
pool instead.
- This flag was introduced to combat
- Run suite hooks in a stack - by @sheremet-va in #5609 (1277d)
- This feels like a more sensible default. Especially with the new
onTestFinished
hook. This can make your tests run a little bit slower.
- This feels like a more sensible default. Especially with the new
- Enable
coverage.ignoreEmptyLines
by default - by @AriPerkkio in #5543 (31994)⚠️ This change may cause significant differences in your coverage results compared to Vitest v1. These changes are expected as coverage reporting is now more accurate. See #5423 for more details.
- Add correct location and snapshot fields in json reporter - by @sheremet-va in #5434 (bcccc)
- Previously, the
location
field pointed to the error location instead of the test location. Now it is aligned with jest and contains theline
andcolumn
of a test function, but requiresincludeTaskLocation
to be enabled.
- Previously, the
- Update dependency chai to v5 - by renovate[bot] and @sheremet-va in #5135 (73646)
- Remove watchExclude - by @patak-dev in #5177 (d7371)
- Change default
pool
to'forks'
- by @AriPerkkio in #5047 (7f8f9)- This change is done for compatibility issues
- This pool may be slightly slower than previous
threads
pool: https://vitest.dev/guide/improving-performance.html#pool
--merge-reports
to support coverage - by @AriPerkkio in #5736 (b7438)- Add promise-based return assertions, do not auto-resolve returned promises - by @sheremet-va in #5749 (5f710)
⚠️ Vitest no longer unwraps promises inspy.mock.returns
. If the function is async or returns a promise, it will always succeed and have aPromise
inresults
. To make migration easier, we introducedspy.mock.settledResults
that unwraps promises andexpect().toHaveResolved()
matcher that accepts unwrapped value.
- Do not exit process if global setup has failed - by @sheremet-va in #5726 (ddb09)
- Don't exit process if config failed - by @sheremet-va in #5715 (f232f)
- Add meta to
json
output - by @sheremet-va in #5802 (dd754) - Rename
indexScripts
toorchestratorScripts
in the browser config - by @sheremet-va in #5842 (49f34) - Add "vitest list" API to print collected tests without running them - by @sheremet-va in #6013 (583dd)
⚠️ This changes the custompool
API - now requirescollectTests
method alongsiderunTests
.
- Remove the empty suite from the runner - by @sheremet-va in #5435 (dbbbe)
- Support concurrent suites - by @hi-ogawa in #5491 (222ce44)
- Support overriding
exclude
in coverage - by @AriPerkkio in #5997 (169bc)⚠️ Vitest coverage no longer adds test files toexclude
patterns ifcoverage.exclude
was overridden in the config. Add your test patterns manually, or merge your overrides with default ones:['**/my-pattern.js', ...coverageConfigDefaults.exclude]
. See https://vitest.dev/config/#coverage-exclude for an example.
- api:
- Remove
process.exit
if workspace project failed to be created - by @sheremet-va in #5804 (a820e) - Don't call
process.exit
manually - by @sheremet-va in #5926 (e9b63)
- Remove
🚀 Features
- browser:
- 🌐 This release lays the groundwork for the next iteration of Vitest Browser Mode. You can read more about our future plans at https://github.com/vitest-dev/vitest/discussions/5828
- Add commands to communicate betweens server and the browser - by @sheremet-va in #5097 (aa431)
- Do not reload the page during watch mode - by @sheremet-va in #5810 (e5b9a)
- Support changing the viewport - by @sheremet-va in #5811 (71851)
- Add browser iframe mouse interaction - by @userquin in #5815 (f29b9)
- Support
click
event - by @sheremet-va in #5777 (839c3) - Rename none provider to preview, make it default - by @sheremet-va in #5826 (18310)
- Run tests in parallel in headless mode, add
page.screenshot
method - by @sheremet-va in #5853 (81c42) - Implement several
userEvent
methods, addfill
anddragAndDrop
events - by @sheremet-va in #5882 (4dbea) - Introduce
expect.dom
method and bundlejest-dom
matchers with@vitest/browser
- by @sheremet-va in #5910 (3a96a) - Expose CDP in the browser - by @sheremet-va in #5938 (bec43)
- Add "init" command for browser tests - by @sheremet-va in #5960 (49e97)
- Add an option to take screenshots if the browser test fails - by @sheremet-va in #5975 (154cb)
- Add
tripleClick
to interactive api - by @userquin in #5987 (200a4) - Playwright provider doesn't allow resizing the browser viewport - by @userquin and @sheremet-va in #5984 (ff978)
- Pretty print diffs coming from cause - by @dubzzz in #5660 (6faf8)
- Allow import statement as vi.mock path for better IDE support - by @sheremet-va in #5690 (a99a1)
- Remove deprecated options - by @sheremet-va in #5696 (5c308)
- Add blob reporter - by @sheremet-va in #5663 (e2053)
- ✅ Run Vitest i...
v2.0.0-beta.13
🚨 Breaking Changes
- vitest: Add "vitest list" API to print collected tests without running them - by @sheremet-va in #6013 (583dd)
- api:
- Don't call process.exit manually - by @sheremet-va in #5926 (e9b63)
🚀 Features
- Add an option to return base64 from page.screenshot - by @sheremet-va in #5993 (be323)
- Expose
parseAst
,parseAstAsync
from vite - by @sheremet-va (f645e) - browser:
- config:
- ui:
🐞 Bug Fixes
- Don't override uppercase - by @sheremet-va (caef4)
- Clear screen and scrollback on iTerm2 - by @kxalex in #5978 (d7f23)
- Include pretty-format in @vitest/runner for optimization on npm - by @sheremet-va (42bd4)
- Transpile esnext to node18 to support newest JS and TS features - by @sheremet-va in #4409 (8f65a)
- browser:
- Print screenshot path alongside the test error message - by @sheremet-va in #5992 (15289)
- Print correct stack trace in source files - by @sheremet-va in #6003 (62aa7)
- Correctly mock optimized cjs dependencies - by @sheremet-va in #6035 (057b4)
- Support shadow root and svg elements - by @sheremet-va in #6036 (2e3c8)
- coverage:
- Exclude bench files from coverage - by @kouak in #5983 (429e1)
- Vite to ignore dynamic import of provider - by @AriPerkkio in #5998 (6d884)
- Istanbul to support import attributes - by @Gravitonic in #6006 (2898a)
- Support overriding
exclude
- by @AriPerkkio in #5997 (169bc) - Remove work-around for implicit
else
- by @AriPerkkio in #6014 (368c1)
- vite-node:
- Expose all envs from .env file, not just with a prefix
VITE_
- by @sheremet-va in #6017 (d87be)
- Expose all envs from .env file, not just with a prefix
- vitest:
- Allow testing unandled rejection/exception - by @sheremet-va in #6016 (c8d56)
- Show all failed tests when rerunning a test - by @sheremet-va in #6022 (91ba6)
View changes on GitHub
v2.0.0-beta.12
🚀 Features
- browser:
- Introduce
expect.dom
method and bundlejest-dom
matchers with@vitest/browser
- by @sheremet-va in #5910 (3a96a) - Expose CDP in the browser - by @sheremet-va in #5938 (bec43)
- Add "init" command for browser tests - by @sheremet-va in #5960 (49e97)
- Add an option to take screenshots if the browser test fails - by @sheremet-va in #5975 (154cb)
- Introduce
- spy:
- Collect mock.contexts - by @sheremet-va in #5955 (3b31a)
- ui:
🐞 Bug Fixes
- Use TTY reporter when running in Deno - by @marvinhagemeister in #5972 (e0f45)
- api:
- Correct
project.provide
type - by @sheremet-va in #5959 (0eda9)
- Correct
- browser:
- Remove "util" warning - by @sheremet-va in #5935 (48f28)
- Remove hacky retry - by @sheremet-va in #5971 (2a2c9)
- Make userEvent more stable when running in parallel - by @sheremet-va in #5974 (14a21)
- coverage:
- Pass thresholds errors to
stderr
ofstartVitest()
- by @AriPerkkio in #5954 (70805)
- Pass thresholds errors to
- types:
- Mark pool options as not available in project config - by @sheremet-va in #5934 (486fd)
- ui:
View changes on GitHub
v2.0.0-beta.11
🚀 Features
- Image type add bmp - by @btea in #5921 (98f9b)
- browser: Implement several
userEvent
methods, addfill
anddragAndDrop
events - by @sheremet-va in #5882 (4dbea) - ws-client: Allow change reactive for state, filesMap and idMap - by @userquin in #5906 (e6020)
🐞 Bug Fixes
- ToJSON recursive error serialization - by @eddienubes in #5848 and #5884 (8d55d)
- Print error properties only in verbose reporter - by @sheremet-va in #5917 (2bd8d)
- browser:
- Resolve
coverage.reporter
from string values - by @AriPerkkio in #5920 (f33da) - Correctly update inline snapshot if changed - by @sheremet-va in #5925 (2380c)
- Resolve
- snapshot:
- vitest:
- Expose
provide
to the public API - by @sheremet-va in #5897 (66e64) - Cache fs code only for forks pool - by @sheremet-va in #5909 (e30d9)
- Expose
View changes on GitHub
v2.0.0-beta.10
🚀 Features
- browser: Run tests in parallel in headless mode, add
page.screenshot
method - by @sheremet-va in #5853 (81c42) - runner: Implement
test.for
- by @hi-ogawa and @sheremet-va in #5861 (c2380) - ui: Load module graph on tab selection - by @userquin in #5844 (b117e)
🐞 Bug Fixes
- Vi.waitFor/vi.waitUntil interval is now cleared after it times out - by @pedro00dk in #5875 (04107)
- browser:
- Set server.open to false and move error handling after init - by @sheremet-va in #5845 (47003)
- Show correct prepare time - by @sheremet-va in #5852 (52d54)
- deps:
- forks:
- Resolve
poolOptions.<name>.isolate
fromforks
options - by @AriPerkkio in #5840 (a60a1)
- Resolve
- ui, browser:
- utils:
View changes on GitHub
v2.0.0-beta.9
🐞 Bug Fixes
- browser: Don't optimize Vitest dependencies - by @sheremet-va in #5843 (f15b4)
View changes on GitHub
v2.0.0-beta.8
🚨 Breaking Changes
- Rename indexScripts to orchestratorScripts - by @sheremet-va in #5842 (49f34)
🐞 Bug Fixes
- browser:
- Print correct transformed module graph - by @sheremet-va in #5833 (a7581)
- Use
preview
provider when running in StackBlitz - by @userquin in #5836 (76e13) - Specify entries for correct deps optimization - by @sheremet-va in #5839 (c79b3)
- Allow iframe to load even if there is a custom CSP header - by @sheremet-va in #5841 (caaaf)
View changes on GitHub
v2.0.0-beta.7
🚨 Breaking Changes
- Add meta to json output - by @sheremet-va in #5802 (dd754)
🚀 Features
- browser:
- Support
click
event - by @sheremet-va in #5777 (839c3) - Rename none provider to preview, make it default - by @sheremet-va in #5826 (18310)
- Support
🐞 Bug Fixes
- browser:
- Use iframe id instead of calculating it from filenames - by @sheremet-va in #5823 (34a31)
- Always clean up iframes on rerun - by @sheremet-va in #5827 (087fa)
- Support @testing-library/vue in browser mode out of the box - by @sheremet-va (76b82)
- coverage:
thresholds.autoUpdate
to supportmergeConfig
- by @AriPerkkio in #5818 (7afb3)
- runner:
- Ensure test.each print -0 and -NaN properly - by @pengooseDev in #5806 (9ac8f)
View changes on GitHub
v2.0.0-beta.6
🐞 Bug Fixes
- browser:
- Restore the original viewport when unselecting the preset viewport - by @sheremet-va in #5821 (5ebb3)
- Don't get stuck after the manual page refresh - by @sheremet-va (2220b)
View changes on GitHub
v2.0.0-beta.5
🚨 Breaking Changes
--merge-reports
to support coverage - by @AriPerkkio in #5736 (b7438)- Add promise-based return assertions, do not auto-resolve returned promises - by @sheremet-va in #5749 (5f710)
- Do not exit process if global setup has failed - by @sheremet-va in #5726 (ddb09)
🚀 Features
- Add browser.ui option - by @sheremet-va in #5771 (a5033)
- Add median to
--output-json
- by @Joristdh in #5745 (0766b) - Allow augmenting config.test.env - by @sheremet-va in #5784 (b2469)
- Implement module mocking in browser mode - by @sheremet-va in #5765 (7b2f6)
- Allow configuring expect options in the config - by @sheremet-va in #5729 (fc53f)
- Add an option to print console stack trace - by @sheremet-va in #5720 (e4fe6)
- Add browser frame to UI - by @sheremet-va in #5808 (3796d)
- browser:
- Do not reload the page during watch mode - by @sheremet-va in #5810 (e5b9a)
- Support changing the viewport - by @sheremet-va in #5811 (71851)
- Add browser iframe mouse interaction - by @userquin in #5815 (f29b9)
- ui:
- Render tests in a tree - by @sheremet-va in #5807 (7900f)
🐞 Bug Fixes
- Repeatable
--exclude
option - by @fregante in #5782 (d6700) - Remove browser.fileParallelism - by @sheremet-va in #5790 (b881e)
- Install UI icons - by @sheremet-va (b84f1)
- Remove process.exit if workspace project failed to be created - by @sheremet-va in #5804 (a820e)
- browser:
- coverage:
- Clean up empty coverage reports directory - by @AriPerkkio in #5731 (c469c)
- runner:
- Ensure inner suite { sequential: true } correctly overrides outer suite { concurrent: true } - by @pengooseDev in #5737 (a20e7)
- ui:
- Show correct module graph and project name in a Vitest workspace - by @sheremet-va in #5792 (48c50)
- utils: