From f585e510944f69e3d7104290aa4ff5a6dc0cc5e0 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 26 Feb 2026 20:33:33 +0800 Subject: [PATCH 1/2] feat(reporter): add `testLists` option to md reporter Add a new `testLists` option to `MdReporterOptions` that controls when the `## Tests` section (Passed / Skipped / Todo lists) is displayed. - `'auto'` (default): show only when all tests pass and the run is focused (existing behavior, no breaking change) - `'always'`: always show the test lists regardless of test status or focus Usage: ```ts reporters: [['md', { testLists: 'always' }]] ``` Amp-Thread-ID: https://ampcode.com/threads/T-019c99e1-ac89-74b0-a3be-ce819ce5b7e6 Co-authored-by: Amp --- packages/core/src/reporter/md.ts | 22 ++++++++++++++++++---- packages/core/src/types/reporter.ts | 8 ++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/core/src/reporter/md.ts b/packages/core/src/reporter/md.ts index 20c6e3063..d0dc51b3e 100644 --- a/packages/core/src/reporter/md.ts +++ b/packages/core/src/reporter/md.ts @@ -23,7 +23,8 @@ * passedTests, skippedTests, todoTests), durationMs, snapshot. * * - Tests - * - Printed only when `status === 'pass' && focusedRun === true`. + * - Printed when `options.testLists === 'always'`, or when + * `status === 'pass' && focusedRun === true`. * - Contains `### Passed` and `### Skipped` lists; `### Todo` is printed only * when `todoTests.length > 0`. * - Lists are truncated to `DEFAULT_TEST_LIST_MAX_ITEMS` and may include a @@ -34,7 +35,8 @@ * - When there are no failures (`failures.length === 0`): * - Prints `No test failures reported.` * - Additionally prints `Note: all tests passed. Lists omitted for brevity.` - * only when `status === 'pass' && focusedRun === false`. + * only when `status === 'pass' && focusedRun === false` and + * `options.testLists !== 'always'`. * - When failures exist: * - If truncated (`failures.length > options.failures.max`): * - Prints truncation note with counts. @@ -130,10 +132,13 @@ type ErrorsResolved = { unhandled: boolean; }; +type TestListsMode = NonNullable; + type ResolvedOptions = { preset: NonNullable; header: HeaderOptions; reproduction: false | 'file' | 'file+name'; + testLists: TestListsMode; failures: FailuresOptions; codeFrame: CodeFrameResolved; stack: StackMode; @@ -181,6 +186,7 @@ const defaultOptions: ResolvedOptions = { env: true, }, reproduction: 'file+name', + testLists: 'auto', failures: { max: 50, }, @@ -328,6 +334,7 @@ export const resolveOptions = ( preset: presetName, header: resolveHeader(userOptions.header), reproduction: resolveReproduction(userOptions.reproduction), + testLists: userOptions.testLists ?? defaultOptions.testLists, failures: resolveFailures(userOptions.failures, preset), codeFrame: resolveCodeFrame(userOptions.codeFrame, preset), stack: resolveStack(userOptions.stack, preset), @@ -1062,7 +1069,10 @@ export class MdReporter implements Reporter { pushHeading(lines, 2, 'Summary'); pushFencedBlock(lines, 'json', stringifyJson(summaryPayload)); - if (status === 'pass' && focusedRun) { + if ( + this.options.testLists === 'always' || + (status === 'pass' && focusedRun) + ) { this.renderTestsSection(lines, { passed: passedTests, skipped: skippedTests, @@ -1074,7 +1084,11 @@ export class MdReporter implements Reporter { if (!failures.length) { lines.push('No test failures reported.'); - if (status === 'pass' && !focusedRun) { + if ( + status === 'pass' && + !focusedRun && + this.options.testLists !== 'always' + ) { ensureSingleBlankLine(lines); lines.push('Note: all tests passed. Lists omitted for brevity.'); } diff --git a/packages/core/src/types/reporter.ts b/packages/core/src/types/reporter.ts index 4244d991f..80e8da885 100644 --- a/packages/core/src/types/reporter.ts +++ b/packages/core/src/types/reporter.ts @@ -80,6 +80,14 @@ export type MdReporterOptions = { */ reproduction?: boolean | 'file' | 'file+name'; + /** + * Test lists (Passed / Skipped / Todo) display mode. + * - `'auto'`: show only when all tests pass and the run is focused + * - `'always'`: always show regardless of test status or focus + * @default 'auto' + */ + testLists?: 'auto' | 'always'; + /** * Failure output controls. * @default { max: 50 } From 61f3294e85148a0f584e3b5e6414c6d3b83dd136 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 26 Feb 2026 20:43:53 +0800 Subject: [PATCH 2/2] test(reporter): update md reporter test for testLists default Amp-Thread-ID: https://ampcode.com/threads/T-019c99e1-ac89-74b0-a3be-ce819ce5b7e6 Co-authored-by: Amp --- packages/core/tests/reporter/md.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/tests/reporter/md.test.ts b/packages/core/tests/reporter/md.test.ts index fd4a04933..0387779bb 100644 --- a/packages/core/tests/reporter/md.test.ts +++ b/packages/core/tests/reporter/md.test.ts @@ -10,6 +10,7 @@ describe('resolveOptions', () => { preset: 'normal', header: { env: true }, reproduction: 'file+name', + testLists: 'auto', failures: { max: 50 }, codeFrame: { enabled: true, linesAbove: 2, linesBelow: 2 }, stack: 'top',