Skip to content

Commit bcff128

Browse files
paullewispaulirish
authored andcommitted
Fix scoring exception in handlebars (#509)
1 parent 47c2f96 commit bcff128

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

lighthouse-core/aggregator/aggregate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ class Aggregate {
8585
}
8686

8787
if (typeof result.rawValue !== typeof expected.rawValue) {
88-
return weight;
88+
const msg =
89+
`Expected rawValue of type ${typeof expected.rawValue}, got ${typeof result.rawValue}`;
90+
throw new Error(msg);
8991
}
9092

9193
switch (typeof expected.rawValue) {

lighthouse-core/audits/estimated-input-latency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class EstimatedInputLatency extends Audit {
5656
const latencyPercentiles = TracingProcessor.getRiskToResponsiveness(model, trace, startTime);
5757

5858
const ninetieth = latencyPercentiles.find(result => result.percentile === 0.9);
59-
const rawValue = ninetieth.time.toFixed(1);
59+
const rawValue = parseFloat(ninetieth.time.toFixed(1));
6060

6161
// Use the CDF of a log-normal distribution for scoring.
6262
// 10th Percentile ≈ 58ms

lighthouse-core/audits/first-meaningful-paint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class FirstMeaningfulPaint extends Audit {
8080

8181
resolve(FirstMeaningfulPaint.generateAuditResult({
8282
score: result.score,
83-
rawValue: result.duration,
83+
rawValue: parseFloat(result.duration),
8484
displayValue: `${result.duration}ms`,
8585
debugString: result.debugString,
8686
optimalValue: this.meta.optimalValue,

lighthouse-core/config/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
"weight": 1
229229
},
230230
"content-width": {
231-
"value": true,
231+
"rawValue": true,
232232
"weight": 1
233233
}
234234
}

lighthouse-core/test/aggregator/aggregate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe('Aggregate', () => {
205205
return assert.equal(Aggregate._convertToWeight(result, expected), 0);
206206
});
207207

208-
it('returns a weight of zero if types do not match', () => {
208+
it('throws if types do not match', () => {
209209
const expected = {
210210
rawValue: true,
211211
weight: 10
@@ -217,7 +217,7 @@ describe('Aggregate', () => {
217217
displayValue: '20'
218218
};
219219

220-
return assert.equal(Aggregate._convertToWeight(result, expected), 0);
220+
return assert.throws(_ => Aggregate._convertToWeight(result, expected));
221221
});
222222

223223
it('scores a set correctly (contributesToScore: true)', () => {

0 commit comments

Comments
 (0)