diff --git a/lighthouse-core/scoring.js b/lighthouse-core/scoring.js index 7f61d697b37c..3b8ec8e2197f 100644 --- a/lighthouse-core/scoring.js +++ b/lighthouse-core/scoring.js @@ -15,7 +15,14 @@ class ReportScoring { static arithmeticMean(items) { const results = items.reduce( (result, item) => { - const score = Number(item.score) || 0; + // HACK. remove this in the next PR + // Srsly. The score inconsitency has been very bad. + let itemScore = item.score; + if (typeof item.score === 'boolean') { + itemScore = item.score ? 100 : 0; + } + + const score = Number(itemScore) || 0; const weight = Number(item.weight) || 0; return { weight: result.weight + weight, @@ -70,7 +77,7 @@ class ReportScoring { const categoryScore = ReportScoring.arithmeticMean(scores); // mutate config.categories[].score category.score = categoryScore; - }; + } } } diff --git a/lighthouse-core/test/report/v2/renderer/report-renderer-test.js b/lighthouse-core/test/report/v2/renderer/report-renderer-test.js index b01e8592815d..4440c254f5a6 100644 --- a/lighthouse-core/test/report/v2/renderer/report-renderer-test.js +++ b/lighthouse-core/test/report/v2/renderer/report-renderer-test.js @@ -119,7 +119,7 @@ describe('ReportRenderer V2', () => { const container = renderer._dom._document.body; const originalResults = JSON.parse(JSON.stringify(sampleResults)); renderer.renderReport(sampleResults, container); - assert.deepStrictEqual(sampleResults, originalResults) + assert.deepStrictEqual(sampleResults, originalResults); }).timeout(2000); it('renders a left nav', () => { diff --git a/lighthouse-core/test/runner-test.js b/lighthouse-core/test/runner-test.js index 364a2041bc72..a385799409d9 100644 --- a/lighthouse-core/test/runner-test.js +++ b/lighthouse-core/test/runner-test.js @@ -445,7 +445,7 @@ describe('Runner', () => { assert.equal(results.initialUrl, url); assert.equal(gatherRunnerRunSpy.called, true, 'GatherRunner.run was not called'); assert.equal(results.audits['content-width'].name, 'content-width'); - assert.equal(results.audits['content-width'].score, 100); + assert.equal(results.audits['content-width'].score, true); assert.equal(results.reportCategories[0].score, 100); assert.equal(results.reportCategories[0].audits[0].id, 'content-width'); });