Skip to content

Commit bb65e15

Browse files
authored
fix(reporters): show project in github reporter (#9138)
### Description <!-- Please insert your description here and provide especially info about the "what" this PR is solving --> Resolves #issue-number <!-- You can also add additional context here --> ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed. - [ ] Ideally, include a test that fails without this PR but passes with it. - [ ] Please, don't make changes to `pnpm-lock.yaml` unless you introduce a new test example. - [ ] Please check [Allow edits by maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to make review process faster. Note that this option is not available for repositories that are owned by Github organizations. ### Tests - [ ] Run the tests with `pnpm test:ci`. ### Documentation - [ ] If you introduce new functionality, document it. You can run documentation with `pnpm run docs` command. ### Changesets - [ ] Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with `feat:`, `fix:`, `perf:`, `docs:`, or `chore:`.
1 parent 1c00fb1 commit bb65e15

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// ],
2424

2525
"vitest.ignoreWorkspace": true,
26-
"vitest.configSearchPatternInclude": "test/{core,cli,config,browser}/{vitest,vite}.{config.ts,config.unit.mts}",
26+
"vitest.configSearchPatternInclude": "test/{core,cli,config,browser,reporters}/{vitest,vite}.{config.ts,config.unit.mts}",
2727
"testing.automaticallyOpenTestResults": "neverOpen",
2828

2929
// Enable eslint for all supported languages

packages/vitest/src/node/reporters/github-actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class GithubActionsReporter implements Reporter {
8080
for (const error of task.result?.errors ?? []) {
8181
projectErrors.push({
8282
project,
83-
title,
83+
title: project.name ? `[${project.name}] ${title}` : title,
8484
error,
8585
file,
8686
})

test/reporters/tests/github-actions.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ describe(GithubActionsReporter, () => {
1818
expect(stderr).toBe('')
1919
})
2020

21+
it('prints the project name when there is one', async () => {
22+
let { stdout, stderr } = await runVitest(
23+
{
24+
name: 'test-project',
25+
reporters: new GithubActionsReporter(),
26+
root: './fixtures',
27+
include: ['**/some-failing.test.ts'],
28+
},
29+
)
30+
stdout = stdout.replace(resolve(import.meta.dirname, '..').replace(/:/g, '%3A'), '__TEST_DIR__')
31+
expect(stdout).toMatchInlineSnapshot(`
32+
"
33+
::error file=__TEST_DIR__/fixtures/some-failing.test.ts,title=[test-project] some-failing.test.ts > 3 + 3 = 7,line=8,column=17::AssertionError: expected 6 to be 7 // Object.is equality%0A%0A- Expected%0A+ Received%0A%0A- 7%0A+ 6%0A%0A ❯ some-failing.test.ts:8:17%0A%0A
34+
"
35+
`)
36+
expect(stderr).toBe('')
37+
})
38+
2139
it('uses onWritePath to format path', async () => {
2240
const { stdout, stderr } = await runVitest(
2341
{

0 commit comments

Comments
 (0)