| 8 | import {DefaultReporter} from 'vitest/reporters'; |
| 9 | |
| 10 | export default class extends DefaultReporter { |
| 11 | tests: number = 0; |
| 12 | assertions: number = 0; |
| 13 | async onTestCaseResult(testCase: TestCase) { |
| 14 | this.assertions += (testCase.meta() as any).assertions || 0; |
| 15 | this.tests++; |
| 16 | super.onTestCaseResult(testCase); |
| 17 | } |
| 18 | |
| 19 | async onTestRunEnd( |
| 20 | testModules: ReadonlyArray<TestModule>, |
| 21 | unhandledErrors: ReadonlyArray<SerializedError>, |
| 22 | reason: TestRunEndReason, |
| 23 | ) { |
| 24 | super.onTestRunEnd(testModules, unhandledErrors, reason); |
| 25 | this.ctx.logger.log(`\nTotal Assertions: ${this.assertions}`); |
| 26 | await writeFile( |
| 27 | './tmp/counts.json', |
| 28 | JSON.stringify({tests: this.tests, assertions: this.assertions}), |
| 29 | 'utf8', |
| 30 | ); |
| 31 | } |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected