Skip to content

Commit 83f3c55

Browse files
committed
Found the way to get the file name
1 parent 84d50f9 commit 83f3c55

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/vitest-reporter/build/test-reporter.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/vitest-reporter/src/test-reporter.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fs from 'fs';
2-
import type { Reporter, TestCase, TestModule, TestSuite, Vitest } from 'vitest/node';
2+
import type { Reporter, RunnerTestFile, TestCase, TestModule, TestSuite, Vitest } from 'vitest/node';
33

44
function* formatTestCase(testCase: TestCase) {
55
const passed = testCase.ok();
@@ -62,10 +62,11 @@ export default class GithubActionsSummaryReporter implements Reporter {
6262
this.writeStream.write('## Test Results\n');
6363
for (const testModule of modules) {
6464
const passed = testModule.ok();
65-
const fileName: string = testModule.task ?? 'undefined';
65+
// @ts-expect-error idk where else to get the file information from
66+
const file: RunnerTestFile = testModule.task;
6667
const testCount = getTestCount(testModule);
6768

68-
this.writeStream.write(`${passed ? '✅' : '❌'} \`${fileName}\` (${testCount} test${testCount === 1 ? '' : 's'}) \n`);
69+
this.writeStream.write(`### ${passed ? '✅' : '❌'} \`${file.filepath}\` (${testCount} test${testCount === 1 ? '' : 's'}) \n`);
6970

7071
this.writeStream.write('<ul>');
7172
for (const child of testModule.children) {
@@ -79,7 +80,7 @@ export default class GithubActionsSummaryReporter implements Reporter {
7980
const totalDuration = diagnostics.duration.toFixed(0);
8081

8182
this.writeStream.write('\n\n');
82-
this.writeStream.write(`#### Summary for \`${fileName}\`\n`);
83+
this.writeStream.write(`#### Summary for \`${file.filepath}\`\n`);
8384
this.writeStream.write('<table>\n');
8485
this.writeStream.write(formatRow('Test Files', ''));
8586
this.writeStream.write(formatRow('Tests', testCount.toString()));

0 commit comments

Comments
 (0)