[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

docs: update reporters guide (#8524)

authored by

Vladimir and committed by
GitHub
(Feb 2, 2026, 2:57 PM +0100) 8ed3cc74 aa9fc38f

+13 -24
+13 -24
docs/guide/advanced/reporters.md
··· 4 4 This is an advanced API. If you just want to configure built-in reporters, read the ["Reporters"](/guide/reporters) guide. 5 5 ::: 6 6 7 - You can import reporters from `vitest/reporters` and extend them to create your custom reporters. 7 + You can import reporters from `vitest/node` and extend them to create your custom reporters. 8 8 9 9 ## Extending Built-in Reporters 10 10 ··· 18 18 } 19 19 ``` 20 20 21 - Of course, you can create your reporter from scratch. Just extend the `BaseReporter` class and implement the methods you need. 21 + ::: warning 22 + However, note that exposed reports are not considered stable and can change the shape of their API within a minor version. 23 + ::: 24 + 25 + Of course, you can create your reporter from scratch. Just implement the [`Reporter`](/api/advanced/reporters) interface: 22 26 23 27 And here is an example of a custom reporter: 24 - 25 - ```ts [custom-reporter.js] 26 - import { BaseReporter } from 'vitest/node' 27 - 28 - export default class CustomReporter extends BaseReporter { 29 - onTestModuleCollected() { 30 - const files = this.ctx.state.getFiles(this.watchFilters) 31 - this.reportTestSummary(files) 32 - } 33 - } 34 - ``` 35 - 36 - Or implement the `Reporter` interface: 37 28 38 29 ```ts [custom-reporter.js] 39 30 import type { Reporter } from 'vitest/node' 40 31 41 32 export default class CustomReporter implements Reporter { 42 - onTestModuleCollected() { 43 - // print something 33 + onTestModuleCollected(testModule) { 34 + console.log(testModule.moduleId, 'is finished') 35 + 36 + for (const test of testModule.children.allTests()) { 37 + console.log(test.name, test.result().state) 38 + } 44 39 } 45 40 } 46 41 ``` ··· 60 55 61 56 ## Reported Tasks 62 57 63 - Instead of using the tasks that reporters receive, it is recommended to use the Reported Tasks API instead. 64 - 65 - You can get access to this API by calling `vitest.state.getReportedEntity(runnerTask)`: 58 + Reported [events](/api/advanced/reporters) receive tasks for [tests](/api/advanced/test-case), [suites](/api/advanced/test-suite) and [modules](/api/advanced/test-module): 66 59 67 60 ```ts twoslash 68 61 import type { Reporter, TestModule } from 'vitest/node' ··· 94 87 7. `TapFlatReporter` 95 88 8. `HangingProcessReporter` 96 89 9. `TreeReporter` 97 - 98 - ### Base Abstract reporters: 99 - 100 - 1. `BaseReporter` 101 90 102 91 ### Interface reporters: 103 92