Skip to content

Commit d8a7eb2

Browse files
committed
fix(utils): always log single perfect audit
1 parent 924a8bf commit d8a7eb2

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/utils/src/lib/reports/log-stdout-summary.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ export function logPlugins(
3939
): void {
4040
plugins.forEach(plugin => {
4141
const { title, audits } = plugin;
42-
const filteredAudits = verbose
43-
? audits
44-
: audits.filter(({ score }) => score !== 1);
42+
const filteredAudits =
43+
verbose || audits.length === 1
44+
? audits
45+
: audits.filter(({ score }) => score !== 1);
4546
const diff = audits.length - filteredAudits.length;
4647

4748
logAudits(title, filteredAudits);

packages/utils/src/lib/reports/log-stdout-summary.unit.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,21 @@ describe('logPlugins', () => {
255255
expect(output).toContain('Audit 1');
256256
expect(output).toContain('Audit 2');
257257
});
258+
259+
it('should not truncate a perfect audit in non-verbose mode when it is the only audit available', () => {
260+
logPlugins(
261+
[
262+
{
263+
title: 'Best Practices',
264+
slug: 'best-practices',
265+
audits: [{ title: 'Audit 1', score: 1, value: 100 }],
266+
},
267+
] as ScoredReport['plugins'],
268+
false,
269+
);
270+
const output = logs.join('\n');
271+
expect(output).toContain('Audit 1');
272+
});
258273
});
259274

260275
describe('binaryIconPrefix', () => {

0 commit comments

Comments
 (0)