Packages

@vitest/ui

5.1.0 · 2 Nov 2026MIT29.9M / weekRepositoryHomepagenpmAtom feed

Your version

0.10.0

25 Apr 2022Where it was published

0.34.7 is the newest release of 0.10.x.

In short

1 deprecated2 new1 fixed

  • Deprecated

    From Vitest v0.10.0, the callback style of declaring tests is deprecated.

Release note

Breaking Changes

From Vitest v0.10.0, the callback style of declaring tests is deprecated. You can rewrite them to use async/await functions, or use Promise to mimic the callback style.

- it('should work', (done) => {
+ it('should work', () => new Promise(done => {
    // ...
    done()
- })
+ }))

Features

beforeAll / beforeEach cleanup callback

beforeAll / beforeEach now accepts an optional cleanup function as the return value (equivalent to afterAll / afterEach).

import { beforeAll } from 'vitest'

beforeEach(async () => {
  // called once before each test run
  await startMocking()

  // clean up function, called once after each test run
  return async () => {
    await stopMocking()
  }
})

Learn more at:

Test Context

Inspired by Playwright Fixtures, Vitest's test context allows you to define utils, states, and fixtures that can be used in your tests.

import { beforeEach, it } from 'vitest'

beforeEach((context) => {
  // extend context
  context.foo = 'bar'
})

it('should work', ({ foo }) => {
  console.log(foo) // 'bar'
})

Learn more at Test Context

Concurrent Snapshot

Due to the limitation of JavaScript, timing based Singleton pattern will cause conflicts when running multiple async functions in concurrent. Previously reported as #551. Thanks to the newly introduced Test Context, we can now provide a test specific expect instance to avoid conflicts. To use it, you can destructure the expect from each test context instead of the global one.

test.concurrent('test 1', async ({ expect }) => {
  expect(foo).toMatchSnapshot()
})
test.concurrent('test 2', async ({ expect }) => {
  expect(foo).toMatchSnapshot()
})

Reporter from file / package

Now you can pass a path to file, or a package name to the reporters options to use custom reporter. Thanks to @ericjgagnon

Bug Fixes

  • Types for EachFunction are missing awaitable return (fix: #1181)

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.