Skip to content

Commit

Permalink
feat(cli): print audit title and documentation link
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Oct 21, 2019
1 parent 2bb88a6 commit 261fd0a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/cli/src/assert/assert.js
Expand Up @@ -72,12 +72,23 @@ async function runCommand(options) {
for (const result of sortedResults) {
hasFailure = hasFailure || result.level === 'error';
const label = result.level === 'warn' ? 'warning' : 'failure';
const warningOrErrorIcon = result.level === 'warn' ? '⚠️ ' : `${log.redify(log.cross)} `;
const icon = result.level === 'warn' ? '⚠️ ' : `${log.redify(log.cross)} `;
const idPart = `${log.bold}${result.auditId}${log.reset}`;
const propertyPart = result.auditProperty ? `.${result.auditProperty}` : '';
const namePart = `${log.bold}${result.name}${log.reset}`;

const auditTitlePart = result.auditTitle || '';
const documentationPart = result.auditDocumentationLink
? `Documentation: ${result.auditDocumentationLink}`
: '';
const titleAndDocs = [auditTitlePart, documentationPart]
.filter(Boolean)
.map(s => ` ` + s)
.join('\n');
const humanFriendlyParts = titleAndDocs ? `\n${titleAndDocs}\n` : '';

process.stderr.write(`
${warningOrErrorIcon} ${idPart}${propertyPart} ${label} for ${namePart} assertion
${icon} ${idPart}${propertyPart} ${label} for ${namePart} assertion${humanFriendlyParts}
expected: ${result.operator}${log.greenify(result.expected)}
found: ${log.redify(result.actual)}
${log.dim}all values: ${result.values.join(', ')}${log.reset}\n\n`);
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/test/autorun.test.js
Expand Up @@ -56,6 +56,9 @@ describe('Lighthouse CI autorun CLI', () => {
1 result(s) for http://localhost:XXXX/good.html
✘ viewport failure for minScore assertion
Does not have a \`<meta name=\\"viewport\\">\` tag with \`width\` or \`initial-scale\`
Documentation: https://web.dev/viewport
expected: >=1
found: 0
all values: 0, 0, 0
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/test/cli.test.js
Expand Up @@ -234,6 +234,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/
✘ works-offline failure for minScore assertion
Current page does not respond with a 200 when offline
Documentation: https://web.dev/works-offline
expected: >=1
found: 0
all values: 0, 0
Expand Down Expand Up @@ -265,6 +268,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/
✘ performance-budget.script.size failure for maxNumericValue assertion
Performance budget
Documentation: https://developers.google.com/web/tools/lighthouse/audits/budgets
expected: <=XXXX
found: XXXX
all values: XXXX
Expand Down Expand Up @@ -295,12 +301,18 @@ describe('Lighthouse CI CLI', () => {
2 result(s) for http://localhost:XXXX/app/
✘ first-contentful-paint failure for maxNumericValue assertion
First Contentful Paint
Documentation: https://web.dev/first-contentful-paint
expected: <=1
found: XXXX
all values: XXXX, XXXX
✘ performance-budget.script.size failure for maxNumericValue assertion
Performance budget
Documentation: https://developers.google.com/web/tools/lighthouse/audits/budgets
expected: <=XXXX
found: XXXX
all values: XXXX
Expand Down Expand Up @@ -329,6 +341,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/
✘ resource-summary.script.size failure for maxNumericValue assertion
Keep request counts low and transfer sizes small
Documentation: https://developers.google.com/web/tools/lighthouse/audits/budgets
expected: <=1
found: XXXX
all values: XXXX, XXXX
Expand Down

0 comments on commit 261fd0a

Please sign in to comment.