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

test: use predictable numbers in golden LHR #6404

Merged
merged 8 commits into from
Oct 29, 2018
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
16 changes: 15 additions & 1 deletion lighthouse-core/scripts/cleanup-LHR-for-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,23 @@ writeFileSync(filename, cleanAndFormatLHR(data), 'utf8');
* @return {string}
*/
function cleanAndFormatLHR(lhrString) {
/** @type {LH.Result} */
const lhr = JSON.parse(lhrString);

// TODO: Resolve the below so we don't need to delete it:
// 1) The string|boolean story for proto
// 2) Travis gets a absolute path during yarn diff:sample-json
delete lhr.configSettings.auditMode;
delete lhr.timing;

// Set timing values, which change from run to run, to predictable values
lhr.timing.total = 12345.6789;
lhr.timing.entries.forEach(entry => {
// @ts-ignore - write to readonly property
entry.duration = 100;
Copy link
Member

@brendankenny brendankenny Oct 26, 2018

Choose a reason for hiding this comment

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

why are these ignored? readonly? Maybe we don't want them to descend from PerformanceEntry after all :)

Should put a reason why it's being ignored. e.g. // @ts-ignore - write to readonly property or whatever

// @ts-ignore - write to readonly property
entry.startTime = 0; // Not realsitic, but avoids a lot of diff churn
});

if (extraFlag !== '--only-remove-timing') {
for (const auditResult of Object.values(lhr.audits)) {
auditResult.description = '**Excluded from diff**';
Expand Down
3 changes: 3 additions & 0 deletions lighthouse-core/test/report/proto-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ describe('round trip JSON comparison subsets', () => {
});
});

// Note: In a failing diff, if you see details.summary going from {} to null, it's OK.
// Jest considers this not a failure, and neither do we, here in the python roundtrip
// Meanwhile, The PSI roundtrip maintains {} to {}.
describe('round trip JSON comparison to everything', () => {
let sampleJson;

Expand Down
Loading