11import fs from 'fs' ;
2- import type { RunnerTestFile , TestCase , TestModule , TestSuite , Vitest } from 'vitest/node' ;
3- import { BasicReporter } from 'vitest/reporters' ;
2+ import type { Reporter , TestCase , TestModule , TestSuite , Vitest } from 'vitest/node' ;
43
54function * formatTestCase ( testCase : TestCase , prefixes : string [ ] ) {
65 const passed = testCase . ok ( ) ;
@@ -37,7 +36,7 @@ function getTestCount(item: TestModule | TestSuite | TestCase): number {
3736 return output ;
3837}
3938
40- export default class GithubActionsSummaryReporter extends BasicReporter {
39+ export default class GithubActionsSummaryReporter implements Reporter {
4140 private writeStream : fs . WriteStream | null = null ;
4241 private vitest : Vitest | null = null ;
4342
@@ -49,18 +48,15 @@ export default class GithubActionsSummaryReporter extends BasicReporter {
4948 }
5049 }
5150
52- onTestRunEnd ( files : RunnerTestFile [ ] ) {
51+ onTestRunEnd ( modules : readonly TestModule [ ] ) {
5352 if ( ! this . writeStream ) return ;
5453
5554 this . writeStream . write ( '<h3>Test Results</h3>' ) ;
56- for ( const file of files ) {
57- const testModule = this . vitest ! . state . getReportedEntity ( file ) as TestModule ;
58- if ( testModule === undefined ) continue ;
59-
55+ for ( const testModule of modules ) {
6056 const passed = testModule . ok ( ) ;
6157 const testCount = getTestCount ( testModule ) ;
6258
63- this . writeStream . write ( `${ passed ? '✅' : '❌' } \` ${ file . filepath } \` (${ testCount } test${ testCount === 1 ? '' : 's' } ) \n` ) ;
59+ this . writeStream . write ( `${ passed ? '✅' : '❌' } (fileName) (${ testCount } test${ testCount === 1 ? '' : 's' } ) \n` ) ;
6460
6561 for ( const child of testModule . children ) {
6662 const formatter = child . type === 'suite' ? formatTestSuite ( child , [ ] ) : formatTestCase ( child , [ ] ) ;
0 commit comments