diff --git a/e2eTests/generateHtmlReport/generateReportConfig.json b/e2eTests/generateHtmlReport/generateReportConfig.json index f5e590c..c0505db 100644 --- a/e2eTests/generateHtmlReport/generateReportConfig.json +++ b/e2eTests/generateHtmlReport/generateReportConfig.json @@ -7,7 +7,8 @@ "scenarios": [ { "url": "http:/google.com/", - "label": "homepage" + "label": "homepage", + "viewports": [{"height": 2400, "width": 1024, "label": "large"}] }] } diff --git a/src/generateReport.js b/src/generateReport.js index 57af790..9f02eb0 100644 --- a/src/generateReport.js +++ b/src/generateReport.js @@ -8,27 +8,29 @@ const createReportData = config => { const report = []; for (let i = 0; i < config.scenarios.length; i++) { - const imageName = `${config.scenarios[i].label}.png`; - const baselinePath = path.resolve(`${config.baseline}/${imageName}`); - const latestPath = path.resolve(`${config.latest}/${imageName}`); - const generatedDiffsPath = path.resolve( - `${config.generatedDiffs}/${imageName}` - ); + const scenario = config.scenarios[i]; + scenario.viewports.forEach(viewport => { + const name = `${scenario.label}-${viewport.label}`; + const imageName = `${name}.png`; - if (fs.existsSync(generatedDiffsPath)) { - logger.info( - 'generate-report', - `found diff for ${config.scenarios[i].label}` + const baselinePath = path.resolve(`${config.baseline}/${imageName}`); + const latestPath = path.resolve(`${config.latest}/${imageName}`); + const generatedDiffsPath = path.resolve( + `${config.generatedDiffs}/${imageName}` ); - const scenarioData = { - label: config.scenarios[i].label, - baseline: baselinePath, - latest: latestPath, - generatedDiff: generatedDiffsPath - }; - report.push(scenarioData); - } + if (fs.existsSync(generatedDiffsPath)) { + logger.info('generate-report', `found diff for ${name}`); + const scenarioData = { + label: name, + baseline: baselinePath, + latest: latestPath, + generatedDiff: generatedDiffsPath + }; + + report.push(scenarioData); + } + }); } return report; }; diff --git a/src/snapshotter.test.js b/src/snapshotter.test.js index ad10ee2..2cd9d6a 100644 --- a/src/snapshotter.test.js +++ b/src/snapshotter.test.js @@ -153,7 +153,7 @@ describe('The snapshotter', () => { expect(seleniumMock).toBeCalledWith(mockSnapshot.driver); }); - it.only('Throws an error if incorrect script file is provided', async () => { + it('Throws an error if incorrect script file is provided', async () => { const config = { gridUrl: 'https://lol.com', url: 'http://cps-render-ci.elb.tnl-dev.ntch.co.uk/',