Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): upgrade to Lighthouse 6.2.0 #416

Merged
merged 2 commits into from
Aug 18, 2020
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
1 change: 1 addition & 0 deletions .lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
assertions: {
'dom-size': ['error', {maxNumericValue: 3000}],

'unsized-images': 'off',
'uses-rel-preload': 'off',
'uses-responsive-images': 'off',
'uses-rel-preconnect': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"express": "^4.17.1",
"inquirer": "^6.3.1",
"isomorphic-fetch": "^2.2.1",
"lighthouse": "6.0.0",
"lighthouse": "6.2.0",
"lighthouse-logger": "1.2.0",
"open": "^7.1.0",
"tmp": "^0.1.0",
Expand Down
36 changes: 18 additions & 18 deletions packages/cli/test/assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ describe('Lighthouse CI assert CLI', () => {
it('should run the recommended preset', async () => {
const result = await run([`--preset=lighthouse:recommended`]);
expect(result.status).toEqual(1);
expect(result.failures).toHaveLength(90);
expect(result.warnings).toHaveLength(17);
expect(result.passes).toHaveLength(0);
expect(result.failures.length).toMatchInlineSnapshot(`94`);
expect(result.warnings.length).toMatchInlineSnapshot(`19`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
expect(result.failures).toContain('viewport failure');
});

it('should run the no-pwa preset', async () => {
const result = await run([`--preset=lighthouse:no-pwa`]);
expect(result.status).toEqual(1);
expect(result.failures).toHaveLength(79);
expect(result.warnings).toHaveLength(15);
expect(result.passes).toHaveLength(0);
expect(result.failures.length).toMatchInlineSnapshot(`83`);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
expect(result.failures).not.toContain('viewport failure');
});
Expand All @@ -83,27 +83,27 @@ describe('Lighthouse CI assert CLI', () => {
it('should return passing audits', async () => {
const result = await run([`--preset=lighthouse:recommended`, '--include-passed-assertions']);
expect(result.status).toEqual(1);
expect(result.warnings).toHaveLength(17);
expect(result.failures).toHaveLength(90);
expect(result.passes).toHaveLength(1);
expect(result.warnings.length).toMatchInlineSnapshot(`19`);
expect(result.failures.length).toMatchInlineSnapshot(`94`);
expect(result.passes.length).toMatchInlineSnapshot(`1`);
expect(result.passes).toContain('first-contentful-paint passing');
expect(result.failures).toContain('viewport failure');
});

it('should set the status code of failures appropriately', async () => {
const result = await run([`--assertions.deprecations=error`]);
expect(result.status).toEqual(1);
expect(result.failures).toHaveLength(1);
expect(result.warnings).toHaveLength(0);
expect(result.passes).toHaveLength(0);
expect(result.failures.length).toMatchInlineSnapshot(`1`);
expect(result.warnings.length).toMatchInlineSnapshot(`0`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
});

it('should set the status code of warnings appropriately', async () => {
const result = await run([`--assertions.deprecations=warn`, '--include-passed-assertions']);
expect(result.status).toEqual(0);
expect(result.failures).toHaveLength(0);
expect(result.warnings).toHaveLength(1);
expect(result.passes).toHaveLength(0);
expect(result.failures.length).toMatchInlineSnapshot(`0`);
expect(result.warnings.length).toMatchInlineSnapshot(`1`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
});

it('should set the status code of passes appropriately', async () => {
Expand All @@ -112,8 +112,8 @@ describe('Lighthouse CI assert CLI', () => {
'--include-passed-assertions',
]);
expect(result.status).toEqual(0);
expect(result.failures).toHaveLength(0);
expect(result.warnings).toHaveLength(0);
expect(result.passes).toHaveLength(1);
expect(result.failures.length).toMatchInlineSnapshot(`0`);
expect(result.warnings.length).toMatchInlineSnapshot(`0`);
expect(result.passes.length).toMatchInlineSnapshot(`1`);
});
});
2 changes: 1 addition & 1 deletion packages/cli/test/autorun-start-server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Lighthouse CI autorun CLI with startServerCommand', () => {

X viewport failure for minScore assertion
Does not have a \`<meta name=\\"viewport\\">\` tag with \`width\` or \`initial-scale\`
https://web.dev/viewport
https://web.dev/viewport/

expected: >=0.9
found: 0
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/test/autorun-static-dir.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Lighthouse CI autorun CLI', () => {

X viewport failure for minScore assertion
Does not have a \`<meta name=\\"viewport\\">\` tag with \`width\` or \`initial-scale\`
https://web.dev/viewport
https://web.dev/viewport/

expected: >=0.9
found: 0
Expand All @@ -73,7 +73,7 @@ describe('Lighthouse CI autorun CLI', () => {

X viewport failure for minScore assertion
Does not have a \`<meta name=\\"viewport\\">\` tag with \`width\` or \`initial-scale\`
https://web.dev/viewport
https://web.dev/viewport/

expected: >=0.9
found: 0
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ describe('Lighthouse CI CLI', () => {

X works-offline failure for minScore assertion
Current page does not respond with a 200 when offline
https://web.dev/works-offline
https://web.dev/works-offline/

expected: >=0.9
found: 0
Expand Down Expand Up @@ -372,7 +372,7 @@ describe('Lighthouse CI CLI', () => {

X works-offline failure for minScore assertion
Current page does not respond with a 200 when offline
https://web.dev/works-offline
https://web.dev/works-offline/

expected: >=0.9
found: 0
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('Lighthouse CI CLI', () => {

X first-contentful-paint failure for maxNumericValue assertion
First Contentful Paint
https://web.dev/first-contentful-paint
https://web.dev/first-contentful-paint/

expected: <=1
found: XXXX
Expand Down Expand Up @@ -432,7 +432,7 @@ describe('Lighthouse CI CLI', () => {

X resource-summary.script.size failure for maxNumericValue assertion
Keep request counts low and transfer sizes small
https://developers.google.com/web/tools/lighthouse/audits/budgets
https://web.dev/use-lighthouse-for-performance-budgets/

expected: <=XXXX
found: XXXX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import lhr5A_ from '../../../../../test/fixtures/lh-5-6-0-verge-a.json';
import lhr5B_ from '../../../../../test/fixtures/lh-5-6-0-verge-b.json';
import lhr6A_ from '../../../../../test/fixtures/lh-6-0-0-coursehero-a.json';
import lhr6B_ from '../../../../../test/fixtures/lh-6-0-0-coursehero-b.json';
import lhr62A_ from '../../../../../test/fixtures/lh-6-2-0-coursehero-a.json';
import lhr62B_ from '../../../../../test/fixtures/lh-6-2-0-coursehero-b.json';

export default {
title: 'Build View/Audit Detail Pane',
Expand All @@ -23,9 +25,12 @@ const lhr5A = /** @type {any} */ (lhr5A_);
const lhr5B = /** @type {any} */ (lhr5B_);
const lhr6A = /** @type {any} */ (lhr6A_);
const lhr6B = /** @type {any} */ (lhr6B_);
const lhr62A = /** @type {any} */ (lhr62A_);
const lhr62B = /** @type {any} */ (lhr62B_);

const auditPairs5 = createAuditPairs(lhr5A, lhr5B);
const auditPairs6 = createAuditPairs(lhr6A, lhr6B);
const auditPairs62 = createAuditPairs(lhr62A, lhr62B);

export const Default = () => (
<AuditDetailPane
Expand All @@ -41,7 +46,16 @@ export const Version6 = () => (
selectedAuditId={auditPairs6[1].audit.id || ''}
setSelectedAuditId={action('setSelectedAuditId')}
pairs={auditPairs6}
baseLhr={lhr5B}
baseLhr={lhr6B}
/>
);

export const Version62 = () => (
<AuditDetailPane
selectedAuditId={auditPairs62[1].audit.id || ''}
setSelectedAuditId={action('setSelectedAuditId')}
pairs={auditPairs62}
baseLhr={lhr62B}
/>
);

Expand All @@ -56,7 +70,7 @@ function createAuditPairs(lhrA, lhrB) {
.filter(group => !group.showAsUnchanged)
.map(group => group.pairs)
.reduce((a, b) => a.concat(b))
// We don't need *all* the audits, so sample ~1/3 of them.
// We don't need *all* the audits, so sample ~1/2 of them.
.filter((pair, i) => i % 2 === 0 && pair.audit.id !== 'uses-long-cache-ttl')
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import lhr5A_ from '../../../../test/fixtures/lh-5-6-0-verge-a.json';
import lhr5B_ from '../../../../test/fixtures/lh-5-6-0-verge-b.json';
import lhr6A_ from '../../../../test/fixtures/lh-6-0-0-coursehero-a.json';
import lhr6B_ from '../../../../test/fixtures/lh-6-0-0-coursehero-b.json';
import lhr62A_ from '../../../../test/fixtures/lh-6-2-0-coursehero-a.json';
import lhr62B_ from '../../../../test/fixtures/lh-6-2-0-coursehero-b.json';

export default {
title: 'Build View/LHR Comparison',
Expand All @@ -21,6 +23,8 @@ const lhr5A = /** @type {any} */ (lhr5A_);
const lhr5B = /** @type {any} */ (lhr5B_);
const lhr6A = /** @type {any} */ (lhr6A_);
const lhr6B = /** @type {any} */ (lhr6B_);
const lhr62A = /** @type {any} */ (lhr62A_);
const lhr62B = /** @type {any} */ (lhr62B_);

/** @param {{children: LHCI.PreactNode}} props */
const Wrapper = ({children}) => <div className="build-hash-selector">{children}</div>;
Expand All @@ -36,3 +40,9 @@ export const Version6 = () => (
<LhrComparison lhr={lhr6A} baseLhr={lhr6B} hookElements={{}} />
</Wrapper>
);

export const Version62 = () => (
<Wrapper>
<LhrComparison lhr={lhr62A} baseLhr={lhr62B} hookElements={{}} />
</Wrapper>
);
12 changes: 12 additions & 0 deletions packages/server/test/api/statistic-definitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@
const baseLhr5_ = require('../fixtures/lh-5-6-0-verge-a.json');
/** @type {any} */
const baseLhr6_ = require('../fixtures/lh-6-0-0-coursehero-a.json');
/** @type {any} */
const baseLhr62_ = require('../fixtures/lh-6-2-0-coursehero-a.json');
const {definitions} = require('../../src/api/statistic-definitions.js');

describe('Statistic Definitions', () => {
/** @type {LH.Result} */
const baseLhr5 = baseLhr5_;
/** @type {LH.Result} */
const baseLhr6 = baseLhr6_;
/** @type {LH.Result} */
const baseLhr62 = baseLhr62_;

describe('meta_lighthouse_version()', () => {
const run = definitions.meta_lighthouse_version;

it('should extract the version', () => {
expect(run([baseLhr5])).toEqual({value: 50600});
expect(run([baseLhr6])).toEqual({value: 60000});
expect(run([baseLhr62])).toEqual({value: 60200});
expect(run([{...baseLhr5, lighthouseVersion: '1.2.3-beta.0'}])).toEqual({value: 10203});
});

Expand All @@ -44,6 +49,7 @@ describe('Statistic Definitions', () => {
high.audits.interactive.numericValue = 100e3;
expect(run([low, high, baseLhr5]).value).toBeCloseTo(43223.58);
expect(run([baseLhr6, low, high]).value).toBeCloseTo(20253.43);
expect(run([high, baseLhr62, low]).value).toBeCloseTo(19669.83);
});
});

Expand All @@ -57,6 +63,7 @@ describe('Statistic Definitions', () => {
high.categories.performance.score = 0.99;
expect(run([low, high, baseLhr5]).value).toBeCloseTo(0.18);
expect(run([baseLhr6, low, high]).value).toBeCloseTo(0.16);
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.28);
});
});

Expand All @@ -70,6 +77,7 @@ describe('Statistic Definitions', () => {
high.categories.performance.score = 0.99;
expect(run([low, high, baseLhr5]).value).toBeCloseTo(0.01);
expect(run([baseLhr6, low, high]).value).toBeCloseTo(0.01);
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.01);
});
});

Expand All @@ -83,17 +91,21 @@ describe('Statistic Definitions', () => {
high.categories.performance.score = 0.99;
expect(run([low, high, baseLhr5]).value).toBeCloseTo(0.99);
expect(run([baseLhr6, low, high]).value).toBeCloseTo(0.99);
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.99);
});
});

describe('auditgroup_a11y-aria_*()', () => {
it('should extract the group count', () => {
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr5])).toEqual({value: 7});
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr6])).toEqual({value: 10});
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr62])).toEqual({value: 10});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr5])).toEqual({value: 0});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr6])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr62])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr5])).toEqual({value: 0});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr6])).toEqual({value: 2});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr62])).toEqual({value: 2});
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ describe('Project dashboard', () => {

expect(commits).toMatchInlineSnapshot(`
Array [
"1240build 6call_splitmasterMay 16 6:00 AM",
"1239build 5call_splitmasterMay 15 6:00 AM",
"1238build 4call_splitmasterMay 14 6:00 AM",
"1237build 3call_splitmasterMay 13 6:00 AM",
"1236build 2call_splitmasterMay 12 6:00 AM",
"1234build 1call_splitmasterMay 11 6:00 AM",
]
`);
});
Expand All @@ -49,7 +50,7 @@ describe('Project dashboard', () => {
return {height: bottom - top, left};
});

await state.page.mouse.move(left + 50, 50 + height * 0.8);
await state.page.mouse.move(left * 1.5, 50 + height * 0.8);
await state.page.waitFor(500);
});

Expand Down
Loading