v0.31.0
🚨 Breaking Changes
-
Remove
browser
from allowed pools insidepoolMatchGlob
config option. Please, use Vitest workspaces for running tests in the browser. -
Move assertion declarations to expect package - by @sheremet-va in #3294 (cf3af)
- The change should be minor:
- declare namespace Vi { + declare module 'vitest' { interface Assertion<T = any> extends CustomMatchers<T> {} interface AsymmetricMatchersContaining extends CustomMatchers {} }
🚀 Features
- Update mock implementation to support ESM runtime, introduce "vi.hoisted" - by @sheremet-va in #3258 (0c09a)
- Bypass ESM import order restriction with
vi.hoisted
to run code before imports are executed:
You can also use it to pass variables tovi.hoisted(() => vi.setSystemTime(new Date(2022, 1, 1)))
vi.mock
:const { mockedMethod } = vi.hoisted(() => { return { mockedMethod: vi.fn() } }) vi.mock('./path/to/module.js', () => { return { originalMethod: mockedMethod } })
- Bypass ESM import order restriction with
- Add repeat method to tests - by @samkevin1 in #2652 (7c8f0)
- Add an option to hide skipped test lines - by @g4rry420 and @sheremet-va in #2745 (9bdb1)
- coverage: Watermarks for c8 - by @AriPerkkio in #3254 (730af)
- ui: Add html coverage - by @userquin and @sheremet-va in #3071 (e24cd)
- watch: Test run cancelling, feat:
--bail
option for cancelling test run - by @AriPerkkio in #3163 (8d460)
🐞 Bug Fixes
- Don't call global setup teardown twice - by @sheremet-va in #3188 (ba3d1)
- Reporter to log version before provider initalizations - by @AriPerkkio in #3131 (481b1)
- Throw an error if Vitest cannot access its internal state - by @sheremet-va in #3250 (fbb14)
- Warning suppression broken - by @IceQub3 in #3270 and #3271 (036de)
- Show correct diff in "toHaveBeenCalledWith" - by @sheremet-va in #3289 (19fcd)
- Don't print esm warning, if package name is not found - by @sheremet-va in #3292 (62c14)
- Support exactOptionalPropertyTypes - by @sheremet-va in #3293 (ba81d)
- Don't inline vite hmr and rollup types - by @sheremet-va in #3291 (1f118)
- browser:
- coverage:
thresholdAutoUpdate
to work withperFile
- by @AriPerkkio in #3182 (29eeb)- Throw error if fail to load built-in provider - by @AriPerkkio in #3217 (0a287)
- Stackblitz hangs with c8 - by @AriPerkkio in #3225 (d9fda)
- C8 to ignore vite's generated helpers - by @AriPerkkio in #3241 (21942)
- Workspaces c8 source maps - by @AriPerkkio in #3226 (efce3)
- docs:
- Correct typo and broken link to WebdriverIO - by @nathanbabcock in #3275 (c7da1)
- spy:
- vite-node:
- vitest:
- Also check for vite relative to vitest package - by @JoshuaKGoldberg and @sheremet-va in #3274 (a3393)
- watch:
- Run test files when added to filesystem - by @AriPerkkio in #3189 (7b2c8)