diff --git a/e2eTests/compare/compareConfig.json b/e2eTests/compare/compareConfig.json index a37e8fa..0d3fd26 100644 --- a/e2eTests/compare/compareConfig.json +++ b/e2eTests/compare/compareConfig.json @@ -3,7 +3,7 @@ "baseline": "./e2eTests/compare/baselineMockImages", "latest": "./e2eTests/compare/latestMockImages", "generatedDiffs": "./e2eTests/compare/generatedDiffs", - "report": "./e2eTests/reports", + "report": "./e2eTests/compare/reports", "remoteBucketName": "aye-spy", "remoteRegion": "eu-west-1", "scenarios": [ diff --git a/e2eTests/compare/compareLocal.test.js b/e2eTests/compare/compareLocal.test.js index 37584f6..2f092e2 100644 --- a/e2eTests/compare/compareLocal.test.js +++ b/e2eTests/compare/compareLocal.test.js @@ -5,29 +5,37 @@ import path from 'path'; import fs from 'fs'; import config from './compareConfig'; +function cleanState(dir) { + if (fs.existsSync(dir)) { + const files = fs.readdirSync(dir); + files.forEach(file => fs.unlinkSync(`${dir}/${file}`)); + fs.rmdirSync(dir); + } +} + describe('e2e Tests compare shots locally', () => { let dirPath; + let reportPath; beforeEach(() => { dirPath = path.resolve(config.generatedDiffs); - - if (fs.existsSync(dirPath)) { - const files = fs.readdirSync(dirPath); - files.forEach(file => fs.unlinkSync(`${dirPath}/${file}`)); - fs.rmdirSync(dirPath); - } + reportPath = path.resolve(config.report); + + cleanState(reportPath); + cleanState(dirPath); }); - it('Compares the latest images with the baseline images', () => { + it('Compares the latest images with the baseline images and generate a report', () => { try { execSync( 'node ./lib/bin/run.js compare --browser chrome --config e2eTests/compare/compareConfig.json' ).toString(); } catch (err) { - expect(err.status).toBe(1); - const files = fs.readdirSync(dirPath); - expect(files).toEqual(['fail-large.png']); + const images = fs.readdirSync(dirPath); + const report = fs.readdirSync(reportPath); + expect(images).toEqual(['fail-large.png']); + expect(report).toEqual(['index.html']); } }); }); diff --git a/e2eTests/generateHtmlReport/generateReportConfig.json b/e2eTests/generateHtmlReport/generateReportConfig.json deleted file mode 100644 index c0505db..0000000 --- a/e2eTests/generateHtmlReport/generateReportConfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "gridUrl": "http://selenium.com:4444/wd/hub", - "baseline": "./e2eTests/generateHtmlReport/baseline", - "latest": "./e2eTests/generateHtmlReport/mockImages", - "generatedDiffs": "./e2eTests/generateHtmlReport/generatedDiffs", - "report": "./e2eTests/generateHtmlReport/reports", - "scenarios": [ - { - "url": "http:/google.com/", - "label": "homepage", - "viewports": [{"height": 2400, "width": 1024, "label": "large"}] - }] - } -