From 5b9ec237ab05bdeee774d944f679514090595ddf Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Tue, 17 Mar 2026 18:17:43 -0700 Subject: [PATCH] feat(repo-tools): output "All tests pass." on silent reporter success Co-Authored-By: Claude Sonnet 4.6 --- .../vitest-reporters/silent-reporter.test.ts | 55 ++++++++++++++++++- .../src/vitest-reporters/silent-reporter.ts | 3 +- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/packages/repo-tools/src/vitest-reporters/silent-reporter.test.ts b/packages/repo-tools/src/vitest-reporters/silent-reporter.test.ts index e8bb1dfc8..2c1093daf 100644 --- a/packages/repo-tools/src/vitest-reporters/silent-reporter.test.ts +++ b/packages/repo-tools/src/vitest-reporters/silent-reporter.test.ts @@ -1,4 +1,6 @@ -import { describe, expect, it } from 'vitest'; +import type { File as VitestFile } from '@vitest/runner'; +import { describe, expect, it, vi } from 'vitest'; +import { DotReporter } from 'vitest/reporters'; import { SilentReporter } from './silent-reporter.ts'; @@ -38,4 +40,55 @@ describe('SilentReporter', () => { // and not 2 levels which would only reach DotReporter }); }); + + describe('reportSummary', () => { + it('writes "All tests pass." when all tests pass', () => { + const reporter = new SilentReporter(); + const writeSpy = vi + .spyOn(process.stdout, 'write') + .mockImplementation(() => true); + + const passingFile = { + result: { state: 'pass' }, + tasks: [], + } as unknown as VitestFile; + reporter.reportSummary([passingFile], []); + + expect(writeSpy).toHaveBeenCalledWith('All tests pass.\n'); + writeSpy.mockRestore(); + }); + + it('calls super.reportSummary when a file fails', () => { + const reporter = new SilentReporter(); + const superSpy = vi + .spyOn(DotReporter.prototype, 'reportSummary') + .mockImplementation(() => undefined); + + const failingFile = { + result: { state: 'fail' }, + tasks: [], + } as unknown as VitestFile; + reporter.reportSummary([failingFile], []); + + expect(superSpy).toHaveBeenCalledWith([failingFile], []); + superSpy.mockRestore(); + }); + + it('calls super.reportSummary when there are errors', () => { + const reporter = new SilentReporter(); + const superSpy = vi + .spyOn(DotReporter.prototype, 'reportSummary') + .mockImplementation(() => undefined); + + const passingFile = { + result: { state: 'pass' }, + tasks: [], + } as unknown as VitestFile; + const error = new Error('unhandled'); + reporter.reportSummary([passingFile], [error]); + + expect(superSpy).toHaveBeenCalledWith([passingFile], [error]); + superSpy.mockRestore(); + }); + }); }); diff --git a/packages/repo-tools/src/vitest-reporters/silent-reporter.ts b/packages/repo-tools/src/vitest-reporters/silent-reporter.ts index 75527c50d..36ca9ae8d 100644 --- a/packages/repo-tools/src/vitest-reporters/silent-reporter.ts +++ b/packages/repo-tools/src/vitest-reporters/silent-reporter.ts @@ -85,8 +85,9 @@ export class SilentReporter extends DotReporter { if (hasFailed || errors.length > 0) { super.reportSummary(files, errors); + } else { + process.stdout.write('All tests pass.\n'); } - // Silent when all pass } }