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

tests(lightwallet): add budget to golden LHR #8870

Merged
merged 2 commits into from
May 6, 2019
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
2 changes: 1 addition & 1 deletion lighthouse-core/scripts/assert-golden-lhr-unchanged.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trap teardown EXIT

colorText "Generating a fresh LHR..." "$purple"
set -x
node "$lhroot_path/lighthouse-cli" -A="$lhroot_path/lighthouse-core/test/results/artifacts" --throttling-method=devtools --quiet --output=json --output-path="$freshLHRPath"
node "$lhroot_path/lighthouse-cli" -A="$lhroot_path/lighthouse-core/test/results/artifacts" --config-path="$lhroot_path/lighthouse-core/test/results/sample-config.js" --quiet --output=json --output-path="$freshLHRPath"
set +x

# remove timing from both
Expand Down
21 changes: 1 addition & 20 deletions lighthouse-core/scripts/update-report-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,10 @@ const assetSaver = require('../lib/asset-saver.js');
const artifactPath = 'lighthouse-core/test/results/artifacts';

const {server} = require('../../lighthouse-cli/test/fixtures/static-server.js');
const budgetedConfig = require('../test/results/sample-config.js');

/** @typedef {import('net').AddressInfo} AddressInfo */

/** @type {LH.Config.Json} */
const budgetedConfig = {
extends: 'lighthouse:default',
settings: {
budgets: [{
resourceSizes: [
{resourceType: 'script', budget: 125},
{resourceType: 'total', budget: 500},
],
timings: [
{metric: 'interactive', budget: 5000, tolerance: 1000},
],
resourceCounts: [
{resourceType: 'third-party', budget: 0},
],
}],
},
};

/**
* Update the report artifacts. If artifactName is set only that artifact will be updated.
* @param {keyof LH.Artifacts=} artifactName
Expand All @@ -52,7 +34,6 @@ async function update(artifactName) {
const url = `http://localhost:${port}/dobetterweb/dbw_tester.html`;
const rawFlags = [
`--gather-mode=${artifactPath}`,
'--throttling-method=devtools',
url,
].join(' ');
const flags = cliFlags.getFlags(rawFlags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,8 @@ describe('ReportRenderer', () => {

const container = renderer._dom._document.body;
const reportElement = renderer.renderReport(sampleResults, container);
// TODO(khempenius): Remove "+1" once budgets renderer code is added.
// Until budgets renderer code is added, JSON vs. DOM comparison will differ by 1.
const notApplicableElementCount = reportElement
.querySelectorAll('.lh-audit--notapplicable').length;
assert.strictEqual(notApplicableCount, notApplicableElementCount + 1);
assert.strictEqual(notApplicableCount, notApplicableElementCount);
});
});
51 changes: 51 additions & 0 deletions lighthouse-core/test/results/sample-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @license Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

/**
* @fileoverview Config used for generating the sample_v2 golden LHR.
*/

/** @type {LH.Config.Json} */
const budgetedConfig = {
extends: 'lighthouse:default',
settings: {
throttlingMethod: 'devtools',
budgets: [{
resourceCounts: [
{resourceType: 'total', budget: 10},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wish we could reuse this for the smokes to keep it in sync :)

{resourceType: 'stylesheet', budget: 2},
{resourceType: 'image', budget: 2},
{resourceType: 'media', budget: 0},
{resourceType: 'font', budget: 1},
{resourceType: 'script', budget: 2},
{resourceType: 'document', budget: 1},
{resourceType: 'other', budget: 2},
{resourceType: 'third-party', budget: 1},
],
resourceSizes: [
{resourceType: 'total', budget: 100},
{resourceType: 'stylesheet', budget: 5},
{resourceType: 'image', budget: 30},
{resourceType: 'media', budget: 0},
{resourceType: 'font', budget: 20},
{resourceType: 'script', budget: 30},
{resourceType: 'document', budget: 15},
{resourceType: 'other', budget: 5},
{resourceType: 'third-party', budget: 25},
],
timings: [
{metric: 'first-contentful-paint', budget: 3000, tolerance: 100},
{metric: 'first-cpu-idle', budget: 2900, tolerance: 100},
{metric: 'interactive', budget: 2900, tolerance: 100},
{metric: 'first-meaningful-paint', budget: 2000, tolerance: 100},
{metric: 'estimated-input-latency', budget: 100, tolerance: 100},
],
}],
},
};

module.exports = budgetedConfig;
Loading