You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/index.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -940,7 +940,7 @@ These hooks will throw an error if they are called outside of the test body.
940
940
941
941
This hook is always called after the test has finished running. It is called after `afterEach` hooks since they can influence the test result. It receives a `TaskResult` object with the current test result.
942
942
943
-
```ts
943
+
```ts {1,5}
944
944
import { onTestFinished, test } from'vitest'
945
945
946
946
test('performs a query', () => {
@@ -953,12 +953,12 @@ test('performs a query', () => {
953
953
::: warning
954
954
If you are running tests concurrently, you should always use `onTestFinished` hook from the test context since Vitest doesn't track concurrent tests in global hooks:
955
955
956
-
```ts
956
+
```ts {3,5}
957
957
import { test } from'vitest'
958
958
959
-
test.concurrent('performs a query', (t) => {
959
+
test.concurrent('performs a query', ({ onTestFinished }) => {
This hook is called only after the test has failed. It is called after `afterEach` hooks since they can influence the test result. It receives a `TaskResult` object with the current test result. This hook is useful for debugging.
995
995
996
-
```ts
996
+
```ts {1,5-7}
997
997
import { onTestFailed, test } from'vitest'
998
998
999
999
test('performs a query', () => {
@@ -1008,10 +1008,10 @@ test('performs a query', () => {
1008
1008
::: warning
1009
1009
If you are running tests concurrently, you should always use `onTestFailed` hook from the test context since Vitest doesn't track concurrent tests in global hooks:
1010
1010
1011
-
```ts
1011
+
```ts {3,5-7}
1012
1012
import { test } from'vitest'
1013
1013
1014
-
test.concurrent('performs a query', (t) => {
1014
+
test.concurrent('performs a query', ({ onTestFailed }) => {
0 commit comments