vitest-dev/vitest
### [`v0.10.0`](https://togithub.com/vitest-dev/vitest/releases/v0.10.0)
[Compare Source](https://togithub.com/vitest-dev/vitest/compare/v0.9.4...v0.10.0)
#### 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.
```diff
- 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`).
```ts
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:
- [`beforeAll`](https://vitest.dev/api/#beforeall)
- [`beforeEach`](https://vitest.dev/api/#beforeeach)
##### Test Context
Inspired by [Playwright Fixtures](https://playwright.dev/docs/test-fixtures), Vitest's test context allows you to define utils, states, and fixtures that can be used in your tests.
```ts
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](https://vitest.dev/guide/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](https://togithub.com/vitest-dev/vitest/issues/551). Thanks to the newly introduced [Test Context](#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.
```ts
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](https://togithub.com/ericjgagnon) ([#1136](https://togithub.com/vitest-dev/vitest/issues/1136)) ([f2bceb2](https://togithub.com/vitest-dev/vitest/commit/f2bceb2))
#### Bug Fixes
- types for EachFunction are missing awaitable return (fix: [#1181](https://togithub.com/vitest-dev/vitest/issues/1181)) ([#1182](https://togithub.com/vitest-dev/vitest/issues/1182)) ([95b1ba4](https://togithub.com/vitest-dev/vitest/commit/95b1ba4))
Configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, click this checkbox.
This PR contains the following updates:
^0.9.4
->^0.10.0
Release Notes
vitest-dev/vitest
### [`v0.10.0`](https://togithub.com/vitest-dev/vitest/releases/v0.10.0) [Compare Source](https://togithub.com/vitest-dev/vitest/compare/v0.9.4...v0.10.0) #### 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. ```diff - 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`). ```ts 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: - [`beforeAll`](https://vitest.dev/api/#beforeall) - [`beforeEach`](https://vitest.dev/api/#beforeeach) ##### Test Context Inspired by [Playwright Fixtures](https://playwright.dev/docs/test-fixtures), Vitest's test context allows you to define utils, states, and fixtures that can be used in your tests. ```ts 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](https://vitest.dev/guide/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](https://togithub.com/vitest-dev/vitest/issues/551). Thanks to the newly introduced [Test Context](#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. ```ts 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](https://togithub.com/ericjgagnon) ([#1136](https://togithub.com/vitest-dev/vitest/issues/1136)) ([f2bceb2](https://togithub.com/vitest-dev/vitest/commit/f2bceb2)) #### Bug Fixes - types for EachFunction are missing awaitable return (fix: [#1181](https://togithub.com/vitest-dev/vitest/issues/1181)) ([#1182](https://togithub.com/vitest-dev/vitest/issues/1182)) ([95b1ba4](https://togithub.com/vitest-dev/vitest/commit/95b1ba4))Configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.