Skip to content

Commit 4a66df6

Browse files
authored
feat: add displayAnnotations option to github-options (#8706)
1 parent e63b17e commit 4a66df6

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

docs/guide/reporters.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,18 @@ export default defineConfig({
564564
})
565565
```
566566

567+
If you are using [Annotations API](/guide/test-annotations), the reporter will automatically inline them in the GitHub UI. You can disable this by setting `displayAnnotations` option to `false`:
568+
569+
```ts
570+
export default defineConfig({
571+
test: {
572+
reporters: [
573+
['github-actions', { displayAnnotations: false }],
574+
],
575+
},
576+
})
577+
```
578+
567579
### Blob Reporter
568580

569581
Stores test results on the machine so they can be later merged using [`--merge-reports`](/guide/cli#merge-reports) command.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { capturePrintError } from '../printError'
1010

1111
export interface GithubActionsReporterOptions {
1212
onWritePath?: (path: string) => string
13+
/**
14+
* @default true
15+
*/
16+
displayAnnotations?: boolean
1317
}
1418

1519
export class GithubActionsReporter implements Reporter {
@@ -25,7 +29,7 @@ export class GithubActionsReporter implements Reporter {
2529
}
2630

2731
onTestCaseAnnotate(testCase: TestCase, annotation: TestAnnotation): void {
28-
if (!annotation.location) {
32+
if (!annotation.location || this.options.displayAnnotations === false) {
2933
return
3034
}
3135

packages/vitest/src/node/reporters/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Reporter, TestRunEndReason } from '../types/reporter'
22
import type { BaseOptions, BaseReporter } from './base'
33
import type { BlobOptions } from './blob'
44
import type { DefaultReporterOptions } from './default'
5+
import type { GithubActionsReporterOptions } from './github-actions'
56
import type { HTMLOptions } from './html'
67
import type { JsonOptions } from './json'
78
import type { JUnitOptions } from './junit'
@@ -71,6 +72,7 @@ export interface BuiltinReporterOptions {
7172
'junit': JUnitOptions
7273
'hanging-process': never
7374
'html': HTMLOptions
75+
'github-actions': GithubActionsReporterOptions
7476
}
7577

7678
export type { ReportedHookContext } from './reported-tasks'

test/core/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default defineConfig({
9595
},
9696
includeTaskLocation: true,
9797
reporters: process.env.GITHUB_ACTIONS
98-
? ['default', 'github-actions']
98+
? ['default', ['github-actions', { displayAnnotations: false }]]
9999
: [['default', { summary: true }], 'hanging-process'],
100100
testNamePattern: '^((?!does not include test that).)*$',
101101
coverage: {

0 commit comments

Comments
 (0)