diff --git a/lighthouse-core/test/report/html/renderer/report-renderer-test.js b/lighthouse-core/test/report/html/renderer/report-renderer-test.js index 56f70f363480..d921e8788dda 100644 --- a/lighthouse-core/test/report/html/renderer/report-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/report-renderer-test.js @@ -21,7 +21,7 @@ let PerformanceCategoryRenderer = null; const CriticalRequestChainRenderer = require( '../../../../report/html/renderer/crc-details-renderer.js'); const ReportRenderer = require('../../../../report/html/renderer/report-renderer.js'); -const sampleResults = require('../../../results/sample_v2.json'); +const sampleResultsOrig = require('../../../results/sample_v2.json'); const TIMESTAMP_REGEX = /\d+, \d{4}.*\d+:\d+/; const TEMPLATE_FILE = fs.readFileSync(__dirname + @@ -29,6 +29,7 @@ const TEMPLATE_FILE = fs.readFileSync(__dirname + describe('ReportRenderer', () => { let renderer; + let sampleResults; beforeAll(() => { global.URL = URL; @@ -57,7 +58,7 @@ describe('ReportRenderer', () => { const detailsRenderer = new DetailsRenderer(dom); const categoryRenderer = new CategoryRenderer(dom, detailsRenderer); renderer = new ReportRenderer(dom, categoryRenderer); - sampleResults.reportCategories = Object.values(sampleResults.categories); + sampleResults = Util.prepareReportResult(sampleResultsOrig); }); afterAll(() => { diff --git a/lighthouse-core/test/report/html/renderer/util-test.js b/lighthouse-core/test/report/html/renderer/util-test.js index 93aab1eb7696..a06aa7c6ff82 100644 --- a/lighthouse-core/test/report/html/renderer/util-test.js +++ b/lighthouse-core/test/report/html/renderer/util-test.js @@ -8,7 +8,6 @@ const assert = require('assert'); const Util = require('../../../../report/html/renderer/util.js'); -const ReportRenderer = require('../../../../report/html/renderer/report-renderer.js'); const sampleResults = require('../../../results/sample_v2.json'); const NBSP = '\xa0'; @@ -169,29 +168,26 @@ describe('util helpers', () => { }); describe('getFinalScreenshot', () => { - const cloneResults = Util.prepareReportResult(sampleResults); - it('gets a datauri as a string', () => { + const cloneResults = Util.prepareReportResult(sampleResults); const datauri = Util.getFinalScreenshot(cloneResults); assert.equal(typeof datauri, 'string'); assert.ok(datauri.startsWith('data:image/jpeg;base64,')); }); it('returns null if there is no perf category', () => { - const lhrWithoutPerf = JSON.parse(JSON.stringify(sampleResults)); - delete lhrWithoutPerf.categories.performance; - lhrWithoutPerf.reportCategories = Object.values(lhrWithoutPerf.categories); + const clonedResults = JSON.parse(JSON.stringify(sampleResults)); + delete clonedResults.categories.performance; + const lhrWithoutPerf = Util.prepareReportResult(clonedResults); const datauri = Util.getFinalScreenshot(lhrWithoutPerf); assert.equal(datauri, null); }); it('returns null if there is no final-screenshot audit', () => { - const lhrNoFinalSS = JSON.parse(JSON.stringify(sampleResults)); - delete lhrNoFinalSS.audits['final-screenshot']; - lhrNoFinalSS.reportCategories = Object.values(lhrNoFinalSS.categories); - ReportRenderer.smooshAuditResultsIntoCategories(lhrNoFinalSS.audits, - lhrNoFinalSS.reportCategories); + const clonedResults = JSON.parse(JSON.stringify(sampleResults)); + delete clonedResults.audits['final-screenshot']; + const lhrNoFinalSS = Util.prepareReportResult(clonedResults); const datauri = Util.getFinalScreenshot(lhrNoFinalSS); assert.equal(datauri, null);