diff --git a/.vscode/settings.json b/.vscode/settings.json index 14991480b..95f06bbd7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,7 +23,7 @@ // ], "vitest.ignoreWorkspace": true, - "vitest.configSearchPatternInclude": "test/{core,cli,config,browser}/{vitest,vite}.{config.ts,config.unit.mts}", + "vitest.configSearchPatternInclude": "test/{core,cli,config,browser,reporters}/{vitest,vite}.{config.ts,config.unit.mts}", "testing.automaticallyOpenTestResults": "neverOpen", // Enable eslint for all supported languages diff --git a/packages/vitest/src/node/reporters/github-actions.ts b/packages/vitest/src/node/reporters/github-actions.ts index 888625db7..092f8aed1 100644 --- a/packages/vitest/src/node/reporters/github-actions.ts +++ b/packages/vitest/src/node/reporters/github-actions.ts @@ -80,7 +80,7 @@ export class GithubActionsReporter implements Reporter { for (const error of task.result?.errors ?? []) { projectErrors.push({ project, - title, + title: project.name ? `[${project.name}] ${title}` : title, error, file, }) diff --git a/test/reporters/tests/github-actions.test.ts b/test/reporters/tests/github-actions.test.ts index 9640d6501..3598510f6 100644 --- a/test/reporters/tests/github-actions.test.ts +++ b/test/reporters/tests/github-actions.test.ts @@ -18,6 +18,24 @@ describe(GithubActionsReporter, () => { expect(stderr).toBe('') }) + it('prints the project name when there is one', async () => { + let { stdout, stderr } = await runVitest( + { + name: 'test-project', + reporters: new GithubActionsReporter(), + root: './fixtures', + include: ['**/some-failing.test.ts'], + }, + ) + stdout = stdout.replace(resolve(import.meta.dirname, '..').replace(/:/g, '%3A'), '__TEST_DIR__') + expect(stdout).toMatchInlineSnapshot(` + " + ::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 + " + `) + expect(stderr).toBe('') + }) + it('uses onWritePath to format path', async () => { const { stdout, stderr } = await runVitest( {