[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix(reporter): allow `dot` reporter to work in non interactive terminals (#7994)

Co-authored-by: Ari Perkkiö <ari.perkkio@gmail.com>

authored by

bstephen1
Ari Perkkiö
and committed by
GitHub
(Jun 4, 2025, 9:19 AM +0300) 6db9f520 5297f322

+15 -60
+1 -54
test/reporters/tests/dot.test.ts
··· 1 1 import { describe, expect, test } from 'vitest' 2 2 import { runVitest } from '../../test-utils' 3 3 4 - describe('{ isTTY: true }', () => { 5 - const isTTY = true 6 - 4 + describe.each([true, false])('{ isTTY: %s }', (isTTY) => { 7 5 test('renders successful tests', async () => { 8 6 const { stdout, stderr } = await runVitest({ 9 7 include: ['./fixtures/ok.test.ts'], ··· 41 39 expect(stdout).toContain('\n--\n') 42 40 expect(stdout).toContain('Test Files 1 skipped (1)') 43 41 expect(stdout).toContain('Tests 1 skipped | 1 todo') 44 - 45 - expect(stderr).toContain('') 46 - }) 47 - }) 48 - 49 - describe('{ isTTY: false }', () => { 50 - const isTTY = false 51 - 52 - test('renders successful tests', async () => { 53 - const { stdout, stderr } = await runVitest({ 54 - include: ['./fixtures/ok.test.ts'], 55 - reporters: [['dot', { isTTY }]], 56 - typecheck: undefined, 57 - }) 58 - 59 - expect(stdout).toContain('✓ fixtures/ok.test.ts') 60 - expect(stdout).toContain('Test Files 1 passed (1)') 61 - expect(stdout).not.toContain('·') 62 - 63 - expect(stderr).toBe('') 64 - }) 65 - 66 - test('renders failing tests', async () => { 67 - const { stdout, stderr } = await runVitest({ 68 - include: ['./fixtures/some-failing.test.ts'], 69 - reporters: [['dot', { isTTY }]], 70 - typecheck: undefined, 71 - }) 72 - 73 - expect(stdout).toContain('❯ fixtures/some-failing.test.ts (2 tests | 1 failed)') 74 - expect(stdout).toContain('✓ 2 + 3 = 5') 75 - expect(stdout).toContain('× 3 + 3 = 7') 76 - expect(stdout).not.toContain('\n·x\n') 77 - 78 - expect(stdout).toContain('Test Files 1 failed (1)') 79 - expect(stdout).toContain('Tests 1 failed | 1 passed') 80 - 81 - expect(stderr).toContain('AssertionError: expected 6 to be 7 // Object.is equality') 82 - }) 83 - 84 - test('renders skipped tests', async () => { 85 - const { stdout, stderr } = await runVitest({ 86 - include: ['./fixtures/all-skipped.test.ts'], 87 - reporters: [['dot', { isTTY }]], 88 - typecheck: undefined, 89 - }) 90 - 91 - expect(stdout).toContain('↓ fixtures/all-skipped.test.ts (2 tests | 2 skipped)') 92 - expect(stdout).toContain('Test Files 1 skipped (1)') 93 - expect(stdout).toContain('Tests 1 skipped | 1 todo') 94 - expect(stdout).not.toContain('\n--\n') 95 42 96 43 expect(stderr).toContain('') 97 44 })
+14 -6
packages/vitest/src/node/reporters/dot.ts
··· 1 1 import type { File, Test } from '@vitest/runner' 2 + import type { Writable } from 'node:stream' 2 3 import type { Vitest } from '../core' 3 4 import type { TestCase, TestModule } from './reported-tasks' 4 5 import c from 'tinyrainbow' ··· 30 31 } 31 32 } 32 33 33 - printTestModule(testModule: TestModule): void { 34 - if (!this.isTTY) { 35 - super.printTestModule(testModule) 36 - } 37 - } 34 + // Ignore default logging of base reporter 35 + printTestModule(): void {} 38 36 39 37 onWatcherRerun(files: string[], trigger?: string): void { 40 38 this.tests.clear() ··· 46 44 if (this.isTTY) { 47 45 const finalLog = formatTests(Array.from(this.tests.values())) 48 46 this.ctx.logger.log(finalLog) 47 + } 48 + else { 49 + this.ctx.logger.log() 49 50 } 50 51 51 52 this.tests.clear() ··· 70 71 } 71 72 72 73 onTestCaseResult(test: TestCase): void { 74 + const result = test.result().state 75 + 76 + // On non-TTY the finished tests are printed immediately 77 + if (!this.isTTY && result !== 'pending') { 78 + (this.ctx.logger.outputStream as Writable).write(formatTests([result])) 79 + } 80 + 73 81 super.onTestCaseResult(test) 74 82 75 83 this.finishedTests.add(test.id) 76 - this.tests.set(test.id, test.result().state || 'skipped') 84 + this.tests.set(test.id, result || 'skipped') 77 85 this.renderer?.schedule() 78 86 } 79 87