diff --git a/docs/config/index.md b/docs/config/index.md index 581498e0eb6c..720155fca9c7 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -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) diff --git a/packages/vitest/src/node/reporters/basic.ts b/packages/vitest/src/node/reporters/basic.ts new file mode 100644 index 000000000000..ea24eb20209d --- /dev/null +++ b/packages/vitest/src/node/reporters/basic.ts @@ -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) + } +} diff --git a/packages/vitest/src/node/reporters/index.ts b/packages/vitest/src/node/reporters/index.ts index 91e4020aba84..60e8f2babc9a 100644 --- a/packages/vitest/src/node/reporters/index.ts +++ b/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' @@ -11,6 +12,7 @@ export { DefaultReporter } export const ReportersMap = { 'default': DefaultReporter, + 'basic': BasicReporter, 'verbose': VerboseReporter, 'dot': DotReporter, 'json': JsonReporter, diff --git a/packages/vitest/src/utils/env.ts b/packages/vitest/src/utils/env.ts index 87c1c22667d2..648a7337ceea 100644 --- a/packages/vitest/src/utils/env.ts +++ b/packages/vitest/src/utils/env.ts @@ -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'