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

track number of completed requests in total-byte-weight extendedInfo #2697

Merged
merged 1 commit into from
Jul 17, 2017
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: 2 additions & 0 deletions lighthouse-core/audits/byte-efficiency/total-byte-weight.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class TotalByteWeight extends ByteEfficiencyAudit {
totalBytes += result.totalBytes;
results.push(result);
});
const totalCompletedRequests = results.length;
results = results.sort((itemA, itemB) => itemB.totalBytes - itemA.totalBytes).slice(0, 10);


Expand Down Expand Up @@ -91,6 +92,7 @@ class TotalByteWeight extends ByteEfficiencyAudit {
extendedInfo: {
value: {
results,
totalCompletedRequests
}
},
details: tableDetails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('Total byte weight audit', () => {
assert.strictEqual(result.score, 100);
const results = result.details.items;
assert.strictEqual(results.length, 3);
assert.strictEqual(result.extendedInfo.value.totalCompletedRequests, 3);
assert.strictEqual(results[0][1].text, `70${NBSP}KB`, 'results are sorted');
});
});
Expand All @@ -69,6 +70,7 @@ describe('Total byte weight audit', () => {
assert.strictEqual(result.rawValue, 4180 * 1024);
const results = result.details.items;
assert.strictEqual(results.length, 10, 'results are clipped at top 10');
assert.strictEqual(result.extendedInfo.value.totalCompletedRequests, 11);
});
});

Expand Down