Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions packages/core/src/reporter/md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -130,10 +132,13 @@ type ErrorsResolved = {
unhandled: boolean;
};

type TestListsMode = NonNullable<MdReporterOptions['testLists']>;

type ResolvedOptions = {
preset: NonNullable<MdReporterOptions['preset']>;
header: HeaderOptions;
reproduction: false | 'file' | 'file+name';
testLists: TestListsMode;
failures: FailuresOptions;
codeFrame: CodeFrameResolved;
stack: StackMode;
Expand Down Expand Up @@ -181,6 +186,7 @@ const defaultOptions: ResolvedOptions = {
env: true,
},
reproduction: 'file+name',
testLists: 'auto',
failures: {
max: 50,
},
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand All @@ -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.');
}
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/types/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 1 addition & 0 deletions packages/core/tests/reporter/md.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading