Skip to content

Commit 5df522f

Browse files
trim21sheremet-va
andauthoredJan 21, 2023
feat: add basic reporter which allow user to use reporter in ci (#2612)
* add basic reporter * extend basic reporter * Update index.md * Update index.md * extend from base reporter * fix lint * override onReRun * only ovverride onWatcherRerun * chore: cleanup * add override back * revert Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
1 parent 5a65675 commit 5df522f

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed
 

‎docs/config/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ Project root
359359
Custom reporters for output. Reporters can be [a Reporter instance](https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/types/reporter.ts) or a string to select built in reporters:
360360

361361
- `'default'` - collapse suites when they pass
362+
- `'basic'` - give a reporter like default reporter give in ci
362363
- `'verbose'` - keep the full task tree visible
363364
- `'dot'` - show each task as a single dot
364365
- `'junit'` - JUnit XML reporter (you can configure `testsuites` tag name with `VITEST_JUNIT_SUITE_NAME` environmental variable)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { BaseReporter } from './base'
2+
import type { File } from '#types'
3+
4+
export class BasicReporter extends BaseReporter {
5+
isTTY = false
6+
7+
reportSummary(files: File[]) {
8+
// non-tty mode doesn't add a new line
9+
this.ctx.logger.log()
10+
return super.reportSummary(files)
11+
}
12+
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BasicReporter } from './basic'
12
import { DefaultReporter } from './default'
23
import { DotReporter } from './dot'
34
import { JsonReporter } from './json'
@@ -11,6 +12,7 @@ export { DefaultReporter }
1112

1213
export const ReportersMap = {
1314
'default': DefaultReporter,
15+
'basic': BasicReporter,
1416
'verbose': VerboseReporter,
1517
'dot': DotReporter,
1618
'json': JsonReporter,

‎packages/vitest/src/utils/env.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const isNode = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window
2-
export const isBrowser = typeof window !== 'undefined'
1+
export const isNode: boolean = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window
2+
export const isBrowser: boolean = typeof window !== 'undefined'

0 commit comments

Comments
 (0)
Please sign in to comment.