Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add basic reporter which allow user to use reporter in ci #2612

Merged
merged 14 commits into from Jan 21, 2023
1 change: 1 addition & 0 deletions docs/config/index.md
Expand Up @@ -353,6 +353,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
27 changes: 27 additions & 0 deletions packages/vitest/src/node/reporters/basic.ts
@@ -0,0 +1,27 @@
import { DefaultReporter } from './default'
import type { UserConsoleLog } from '#types'

export class BasicReporter extends DefaultReporter {
trim21 marked this conversation as resolved.
Show resolved Hide resolved
isTTY = false as const

async onTestRemoved() {
}

onCollected() {
}

async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
await super.onFinished(files, errors)
}

async stopListRender() {
this.renderer = undefined
}

onUserConsoleLog(log: UserConsoleLog) {
if (!this.shouldLog(log))
return

super.onUserConsoleLog(log)
}
}
2 changes: 2 additions & 0 deletions packages/vitest/src/node/reporters/index.ts
@@ -1,3 +1,4 @@
import { BasicReporter } from './basic'
import { DefaultReporter } from './default'
import { DotReporter } from './dot'
import { JsonReporter } from './json'
Expand All @@ -10,6 +11,7 @@ export { DefaultReporter }

export const ReportersMap = {
'default': DefaultReporter,
'basic': BasicReporter,
'verbose': VerboseReporter,
'dot': DotReporter,
'json': JsonReporter,
Expand Down