Skip to content

Commit

Permalink
fix(utils): always log single perfect audit
Browse files Browse the repository at this point in the history
  • Loading branch information
hanna-skryl committed Oct 22, 2024
1 parent 924a8bf commit bbf99b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/utils/src/lib/reports/log-stdout-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ export function logPlugins(
): void {
plugins.forEach(plugin => {
const { title, audits } = plugin;
const filteredAudits = verbose
? audits
: audits.filter(({ score }) => score !== 1);
const filteredAudits =
verbose || audits.length === 1
? audits
: audits.filter(({ score }) => score !== 1);
const diff = audits.length - filteredAudits.length;

logAudits(title, filteredAudits);
Expand Down
15 changes: 15 additions & 0 deletions packages/utils/src/lib/reports/log-stdout-summary.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ describe('logPlugins', () => {
expect(output).toContain('Audit 1');
expect(output).toContain('Audit 2');
});

it('should not truncate a perfect audit in non-verbose mode when it is the only audit available', () => {
logPlugins(
[
{
title: 'Best Practices',
slug: 'best-practices',
audits: [{ title: 'Audit 1', score: 1, value: 100 }],
},
] as ScoredReport['plugins'],
false,
);
const output = logs.join('\n');
expect(output).toContain('Audit 1');
});
});

describe('binaryIconPrefix', () => {
Expand Down

0 comments on commit bbf99b8

Please sign in to comment.