Skip to content

Commit

Permalink
test: updating e2e test for compare local
Browse files Browse the repository at this point in the history
  • Loading branch information
L0wry committed Aug 1, 2018
1 parent 5d86f4c commit 711da1a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion e2eTests/compare/compareConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
28 changes: 18 additions & 10 deletions e2eTests/compare/compareLocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
});
});
14 changes: 0 additions & 14 deletions e2eTests/generateHtmlReport/generateReportConfig.json

This file was deleted.

0 comments on commit 711da1a

Please sign in to comment.