Skip to content

Commit

Permalink
feat: add basic reporter which allow user to use reporter in ci (#2612)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
trim21 and sheremet-va authored Jan 21, 2023
1 parent 5a65675 commit 5df522f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ Project root
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:

- `'default'` - collapse suites when they pass
- `'basic'` - give a reporter like default reporter give in ci
- `'verbose'` - keep the full task tree visible
- `'dot'` - show each task as a single dot
- `'junit'` - JUnit XML reporter (you can configure `testsuites` tag name with `VITEST_JUNIT_SUITE_NAME` environmental variable)
Expand Down
12 changes: 12 additions & 0 deletions packages/vitest/src/node/reporters/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BaseReporter } from './base'
import type { File } from '#types'

export class BasicReporter extends BaseReporter {
isTTY = false

reportSummary(files: File[]) {
// non-tty mode doesn't add a new line
this.ctx.logger.log()
return super.reportSummary(files)
}
}
2 changes: 2 additions & 0 deletions packages/vitest/src/node/reporters/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BasicReporter } from './basic'
import { DefaultReporter } from './default'
import { DotReporter } from './dot'
import { JsonReporter } from './json'
Expand All @@ -11,6 +12,7 @@ export { DefaultReporter }

export const ReportersMap = {
'default': DefaultReporter,
'basic': BasicReporter,
'verbose': VerboseReporter,
'dot': DotReporter,
'json': JsonReporter,
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const isNode = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window
export const isBrowser = typeof window !== 'undefined'
export const isNode: boolean = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window
export const isBrowser: boolean = typeof window !== 'undefined'

0 comments on commit 5df522f

Please sign in to comment.