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
+2-2
Original file line number
Diff line number
Diff line change
@@ -1126,7 +1126,7 @@ These hooks will throw an error if they are called outside of the test body.
1126
1126
1127
1127
### onTestFinished {#ontestfinished}
1128
1128
1129
-
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.
1129
+
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 an `ExtendedContext` object like `beforeEach` and `afterEach`.
1130
1130
1131
1131
```ts {1,5}
1132
1132
import { onTestFinished, test } from'vitest'
@@ -1183,7 +1183,7 @@ This hook is always called in reverse order and is not affected by [`sequence.ho
1183
1183
1184
1184
### onTestFailed
1185
1185
1186
-
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.
1186
+
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 an `ExtendedContext` object like `beforeEach` and `afterEach`. This hook is useful for debugging.
Copy file name to clipboardexpand all lines: docs/guide/migration.md
+4
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,10 @@ import {
42
42
43
43
If you are using `getCurrentSuite().custom()`, the `type` of the returned task is now is equal to `'test'`. The `Custom` type will be removed in Vitest 4.
44
44
45
+
### `onTestFinished` and `onTestFailed` Now Receive a Context
46
+
47
+
The [`onTestFinished`](/api/#ontestfinished) and [`onTestFailed`](/api/#ontestfailed) hooks previously received a test result as the first argument. Now, they receive a test context, like `beforeEach` and `afterEach`.
0 commit comments