Skip to content

Commit 9891bb0

Browse files
authored
Merge branch 'vitest-dev:main' into main
2 parents c504bb4 + 9e4cfd2 commit 9891bb0

443 files changed

Lines changed: 4442 additions & 2594 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
* text=auto eol=lf
22

3-
test/reporters/fixtures/indicator-position.test.js eol=crlf
3+
test/cli/fixtures/reporters/indicator-position.test.js eol=crlf

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ jobs:
223223

224224
- name: Install
225225
run: |
226-
yq -i '.overrides.vite = "npm:rolldown-vite"' pnpm-workspace.yaml
226+
yq -i '.overrides.vite = "npm:vite@beta"' pnpm-workspace.yaml
227227
git add . && git commit -m "ci" && pnpm i --prefer-offline --no-frozen-lockfile
228228
229229
- uses: ./.github/actions/setup-playwright

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ $ npx vitest
7878

7979
## Sponsors
8080

81+
<p align="center">
82+
<a href="https://cdn.jsdelivr.net/gh/sheremet-va/static/vitest/sponsors.svg">
83+
<img src='https://cdn.jsdelivr.net/gh/sheremet-va/static/vitest/sponsors.svg'/>
84+
</a>
85+
</p>
86+
8187
### Vladimir Sponsors
8288

8389
<p align="center">

docs/.vitepress/config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,10 @@ export default ({ mode }: { mode: string }) => {
730730
text: 'Test Environment',
731731
link: '/guide/environment',
732732
},
733+
{
734+
text: 'Test Run Lifecycle',
735+
link: '/guide/lifecycle',
736+
},
733737
{
734738
text: 'Snapshot',
735739
link: '/guide/snapshot',
@@ -858,7 +862,7 @@ export default ({ mode }: { mode: string }) => {
858862
},
859863
{
860864
text: 'Advanced',
861-
collapsed: true,
865+
collapsed: false,
862866
items: [
863867
{
864868
text: 'Getting Started',
@@ -947,7 +951,7 @@ export default ({ mode }: { mode: string }) => {
947951
},
948952
{
949953
text: 'Advanced',
950-
collapsed: true,
954+
collapsed: false,
951955
items: [
952956
{
953957
text: 'Vitest',

docs/.vitepress/sponsors.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ const vitestSponsors = {
2929
img: '/zammad.svg',
3030
},
3131
],
32-
// platinum: [],
32+
platinum: [
33+
{
34+
name: 'Chromatic',
35+
url: 'https://www.chromatic.com/?utm_source=vitest&utm_medium=sponsorship&utm_campaign=vitestSponsorship',
36+
img: '/logo-chromatic.svg',
37+
},
38+
],
3339
gold: [
3440
{
3541
name: 'vital',
@@ -51,11 +57,6 @@ const vitestSponsors = {
5157
url: 'https://www.liminity.se/',
5258
img: '/liminity.svg',
5359
},
54-
{
55-
name: 'Bytebase',
56-
url: 'https://www.bytebase.com/',
57-
img: '/bytebase.svg',
58-
},
5960
],
6061
} satisfies Record<string, Sponsor[]>
6162

@@ -70,11 +71,11 @@ export const sponsors = [
7071
size: 'big',
7172
items: vitestSponsors.special,
7273
},
73-
// {
74-
// tier: 'Platinum Sponsors',
75-
// size: 'big',
76-
// items: vitestSponsors.platinum,
77-
// },
74+
{
75+
tier: 'Platinum Sponsors',
76+
size: 'big',
77+
items: vitestSponsors.platinum,
78+
},
7879
{
7980
tier: 'Gold Sponsors',
8081
size: 'medium',

docs/api/advanced/reporters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Note that since test modules can run in parallel, Vitest will report them in par
3636
This guide lists all supported reporter methods. However, don't forget that instead of creating your own reporter, you can [extend existing one](/guide/advanced/reporters) instead:
3737

3838
```ts [custom-reporter.js]
39-
import { BaseReporter } from 'vitest/reporters'
39+
import { BaseReporter } from 'vitest/node'
4040

4141
export default class CustomReporter extends BaseReporter {
4242
onTestRunEnd(testModules, errors) {

docs/api/advanced/runner.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,12 @@ export interface VitestRunner {
106106
When initiating this class, Vitest passes down Vitest config, - you should expose it as a `config` property:
107107

108108
```ts [runner.ts]
109-
import type { RunnerTestFile } from 'vitest'
110-
import type { VitestRunner, VitestRunnerConfig } from 'vitest/suite'
111-
import { VitestTestRunner } from 'vitest/runners'
109+
import type { RunnerTestFile, SerializedConfig, TestRunner, VitestTestRunner } from 'vitest'
112110

113-
class CustomRunner extends VitestTestRunner implements VitestRunner {
114-
public config: VitestRunnerConfig
111+
class CustomRunner extends TestRunner implements VitestTestRunner {
112+
public config: SerializedConfig
115113

116-
constructor(config: VitestRunnerConfig) {
114+
constructor(config: SerializedConfig) {
117115
this.config = config
118116
}
119117

@@ -281,17 +279,15 @@ Vitest exposes `createTaskCollector` utility to create your own `test` method. I
281279
A task is an object that is part of a suite. It is automatically added to the current suite with a `suite.task` method:
282280

283281
```js [custom.js]
284-
import { createTaskCollector, getCurrentSuite } from 'vitest/suite'
285-
286-
export { afterAll, beforeAll, describe } from 'vitest'
282+
export { afterAll, beforeAll, describe, TestRunner } from 'vitest'
287283

288284
// this function will be called during collection phase:
289285
// don't call function handler here, add it to suite tasks
290286
// with "getCurrentSuite().task()" method
291287
// note: createTaskCollector provides support for "todo"/"each"/...
292-
export const myCustomTask = createTaskCollector(
288+
export const myCustomTask = TestRunner.createTaskCollector(
293289
function (name, fn, timeout) {
294-
getCurrentSuite().task(name, {
290+
TestRunner.getCurrentSuite().task(name, {
295291
...this, // so "todo"/"skip"/... is tracked correctly
296292
meta: {
297293
customPropertyToDifferentiateTask: true

docs/api/advanced/test-suite.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,11 @@ function meta(): TaskMeta
200200
Custom [metadata](/api/advanced/metadata) that was attached to the suite during its execution or collection. The meta can be attached by assigning a property to the `suite.meta` object during a test run:
201201

202202
```ts {7,12}
203-
import { test } from 'vitest'
204-
import { getCurrentSuite } from 'vitest/suite'
203+
import { describe, test, TestRunner } from 'vitest'
205204
206205
describe('the validation works correctly', () => {
207206
// assign "decorated" during collection
208-
const { suite } = getCurrentSuite()
207+
const { suite } = TestRunner.getCurrentSuite()
209208
suite!.meta.decorated = true
210209
211210
test('some test', ({ task }) => {

docs/api/expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ You can use `expect.not` with this matcher to negate the expected value.
17581758

17591759
This method adds custom serializers that are called when creating a snapshot. This is an advanced feature - if you want to know more, please read a [guide on custom serializers](/guide/snapshot#custom-serializer).
17601760

1761-
If you are adding custom serializers, you should call this method inside [`setupFiles`](/config/#setupfiles). This will affect every snapshot.
1761+
If you are adding custom serializers, you should call this method inside [`setupFiles`](/config/setupfiles). This will affect every snapshot.
17621762

17631763
:::tip
17641764
If you previously used Vue CLI with Jest, you might want to install [jest-serializer-vue](https://www.npmjs.com/package/jest-serializer-vue). Otherwise, your snapshots will be wrapped in a string, which cases `"` to be escaped.
@@ -1793,7 +1793,7 @@ test('custom matchers', () => {
17931793
```
17941794

17951795
::: tip
1796-
If you want your matchers to appear in every test, you should call this method inside [`setupFiles`](/config/#setupfiles).
1796+
If you want your matchers to appear in every test, you should call this method inside [`setupFiles`](/config/setupfiles).
17971797
:::
17981798

17991799
This function is compatible with Jest's `expect.extend`, so any library that uses it to create custom matchers will work with Vitest.

docs/api/vi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Substitutes all imported modules from provided `path` with another module. You c
4242

4343
In order to hoist `vi.mock`, Vitest statically analyzes your files. It indicates that `vi` that was not directly imported from the `vitest` package (for example, from some utility file) cannot be used. Use `vi.mock` with `vi` imported from `vitest`, or enable [`globals`](/config/#globals) config option.
4444

45-
Vitest will not mock modules that were imported inside a [setup file](/config/#setupfiles) because they are cached by the time a test file is running. You can call [`vi.resetModules()`](#vi-resetmodules) inside [`vi.hoisted`](#vi-hoisted) to clear all module caches before running a test file.
45+
Vitest will not mock modules that were imported inside a [setup file](/config/setupfiles) because they are cached by the time a test file is running. You can call [`vi.resetModules()`](#vi-resetmodules) inside [`vi.hoisted`](#vi-hoisted) to clear all module caches before running a test file.
4646
:::
4747

4848
If the `factory` function is defined, all imports will return its result. Vitest calls factory only once and caches results for all subsequent imports until [`vi.unmock`](#vi-unmock) or [`vi.doUnmock`](#vi-dounmock) is called.
@@ -168,7 +168,7 @@ axios.get(`/apples/${increment(1)}`)
168168
```
169169

170170
::: warning
171-
Beware that if you don't call `vi.mock`, modules **are not** mocked automatically. To replicate Jest's automocking behaviour, you can call `vi.mock` for each required module inside [`setupFiles`](/config/#setupfiles).
171+
Beware that if you don't call `vi.mock`, modules **are not** mocked automatically. To replicate Jest's automocking behaviour, you can call `vi.mock` for each required module inside [`setupFiles`](/config/setupfiles).
172172
:::
173173

174174
If there is no `__mocks__` folder or a factory provided, Vitest will import the original module and auto-mock all its exports. For the rules applied, see [algorithm](/guide/mocking/modules#automocking-algorithm).

0 commit comments

Comments
 (0)