Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Snapshot makes shot even when its failed on specific functionality #177

Merged
merged 7 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,27 @@ coverage/*

# e2eTest folders
e2eTests/generic/updateBaseline/baseline/*
e2eTests/generic/gridError/baseline/*
e2eTests/generic/nonExistScript/baseline/*
e2eTests/chrome/snap/latest/*
e2eTests/firefox/snap/latest/*

e2eTests/generic/compare/generatedDiffs/*
e2eTests/generic/compare/reports/*

e2eTests/generic/onBeforeSuiteScript/latest/*
e2eTests/generic/gridError/latest/*
e2eTests/generic/nonExistScript/latest/*

e2eTests/chrome/removeElements/latest/*
e2eTests/firefox/removeElements/latest/*

e2eTests/chrome/removeElements/generatedDiffs/*
e2eTests/firefox/removeElements/generatedDiffs/*
e2eTests/chrome/removeElements/reports/*
e2eTests/firefox/removeElements/reports/*

e2eTests/chrome/hideElements/latest/*
e2eTests/firefox/hideElements/latest/*
e2eTests/chrome/hideElements/generatedDiffs/*
e2eTests/firefox/hideElements/generatedDiffs/*
e2eTests/chrome/hideElements/reports/*
e2eTests/firefox/hideElements/reports/*
19 changes: 0 additions & 19 deletions e2eTests/chrome/hideElements/hideElements.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
/* globals expect */

import { execSync } from 'child_process';
import path from 'path';
import fs from 'fs';
import config from './hideElementsConfig';

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 hide elements', () => {
let latestMockImagesPath;

beforeEach(() => {
latestMockImagesPath = path.resolve(config.latest);

cleanState(latestMockImagesPath);
});

it('hides elements using zero opacity', () => {
let exitCode = 0;

Expand Down
19 changes: 0 additions & 19 deletions e2eTests/chrome/removeElements/removeElements.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
/* globals expect */

import { execSync } from 'child_process';
import path from 'path';
import fs from 'fs';
import config from './removeElementsConfig';

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 remove elements', () => {
let latestMockImagesPath;

beforeEach(() => {
latestMockImagesPath = path.resolve(config.latest);

cleanState(latestMockImagesPath);
});

it('remove elements from webpage and compares', () => {
let exitCode = 0;

Expand Down
6 changes: 0 additions & 6 deletions e2eTests/chrome/snap/snapLocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ describe('e2e Tests taking snaps locally', () => {

beforeEach(() => {
dirPath = path.resolve(config.latest);

if (fs.existsSync(dirPath)) {
const files = fs.readdirSync(dirPath);
files.forEach(file => fs.unlinkSync(`${dirPath}/${file}`));
fs.rmdirSync(dirPath);
}
});

it('should successfully take a snapshot', async () => {
Expand Down
8 changes: 5 additions & 3 deletions e2eTests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ version: '3'

services:
hub:
image: selenium/hub:3.141
image: selenium/hub
ports:
- "4444:4444"
networks:
- selenium-grid
firefox:
image: selenium/node-firefox:3.141
image: selenium/node-firefox
environment:
- NODE_MAX_INSTANCES=2
- NODE_MAX_SESSION=2
Expand All @@ -21,7 +21,7 @@ services:
depends_on:
- hub
chrome:
image: selenium/node-chrome:3.141
image: selenium/node-chrome
environment:
- NODE_MAX_INSTANCES=2
- NODE_MAX_SESSION=2
Expand All @@ -48,6 +48,8 @@ services:
- chrome
networks:
- selenium-grid
volumes:
- ./:/home/node/app/e2eTests/

ayespy_report:
image: nginx
Expand Down
Binary file modified e2eTests/firefox/hideElements/baseline/hide-element-large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 0 additions & 19 deletions e2eTests/firefox/hideElements/hideElements.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
/* globals expect */

import { execSync } from 'child_process';
import path from 'path';
import fs from 'fs';
import config from './hideElementsConfig';

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 hide elements', () => {
let latestMockImagesPath;

beforeEach(() => {
latestMockImagesPath = path.resolve(config.latest);

cleanState(latestMockImagesPath);
});

it('hides elements using zero opacity', () => {
let exitCode = 0;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 0 additions & 19 deletions e2eTests/firefox/removeElements/removeElements.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
/* globals expect */

import { execSync } from 'child_process';
import path from 'path';
import fs from 'fs';
import config from './removeElementsConfig';

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 remove elements', () => {
let latestMockImagesPath;

beforeEach(() => {
latestMockImagesPath = path.resolve(config.latest);

cleanState(latestMockImagesPath);
});

it('remove elements from webpage and compares', () => {
let exitCode = 0;

Expand Down
6 changes: 0 additions & 6 deletions e2eTests/firefox/snap/snapLocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ describe('e2e Tests taking snaps locally', () => {

beforeEach(() => {
dirPath = path.resolve(config.latest);

if (fs.existsSync(dirPath)) {
const files = fs.readdirSync(dirPath);
files.forEach(file => fs.unlinkSync(`${dirPath}/${file}`));
fs.rmdirSync(dirPath);
}
});

it('should successfully take a snapshot', async () => {
Expand Down
36 changes: 36 additions & 0 deletions e2eTests/generic/gridError/gridErrorSuiteScript.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* globals expect */

import path from 'path';
import fs from 'fs';
import { execSync } from 'child_process';
import config from './gridErrorSuiteScriptConfig';

describe('e2e Tests running gridErrorSuiteScript', () => {
let dirPath;

beforeEach(() => {
dirPath = path.resolve(config.latest);

if (fs.existsSync(dirPath)) {
const files = fs.readdirSync(dirPath);
files.forEach(file => fs.unlinkSync(`${dirPath}/${file}`));
fs.rmdirSync(dirPath);
}
});

it('throw exception and no snapshot is taken', async () => {
let exitCode = 0;
let stdout;
try {
stdout = execSync(
'node ./lib/bin/run.js snap --browser chrome --config e2eTests/generic/gridError/gridErrorSuiteScriptConfig.json'
).toString();
//pipe stdout to Jest console
console.log(stdout);
} catch (error) {
exitCode = error.status;
}

expect(exitCode).toEqual(1);
});
});
15 changes: 15 additions & 0 deletions e2eTests/generic/gridError/gridErrorSuiteScriptConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"gridUrl": "",
"baseline": "./e2eTests/generic/gridError/baseline",
"latest": "./e2eTests/generic/gridError/latest",
"generatedDiffs": "./e2eTests/generic/gridError/generatedDiffs",
"report": "./e2eTests/generic/gridError/reports",
"remoteBucketName": "aye-spy",
"remoteRegion": "eu-west-1",
"scenarios": [
{
"url": "http://ayespy_report:4000",
"label": "image",
"viewports": [{"height": 2400, "width": 1024, "label": "large"}]
}]
}
36 changes: 36 additions & 0 deletions e2eTests/generic/nonExistScript/nonExistScriptSuiteScript.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* globals expect */

import path from 'path';
import fs from 'fs';
import { execSync } from 'child_process';
import config from './nonExistScriptSuiteScriptConfig';

describe('e2e Tests running nonExistScriptSuiteScript', () => {
let dirPath;

beforeEach(() => {
dirPath = path.resolve(config.latest);

if (fs.existsSync(dirPath)) {
const files = fs.readdirSync(dirPath);
files.forEach(file => fs.unlinkSync(`${dirPath}/${file}`));
fs.rmdirSync(dirPath);
}
});

it('should successfully run the snap with with non exist script', async () => {
let exitCode = 0;
let stdout;
try {
stdout = execSync(
'node ./lib/bin/run.js snap --browser chrome --config e2eTests/generic/nonExistScript/nonExistScriptSuiteScriptConfig.json'
).toString();
//pipe stdout to Jest console
console.log(stdout);
} catch (error) {
exitCode = error.status;
}

expect(exitCode).toEqual(0);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"gridUrl": "http://hub:4444/wd/hub",
"baseline": "./e2eTests/generic/nonExistScript/baseline",
"latest": "./e2eTests/generic/nonExistScript/latest",
"generatedDiffs": "./e2eTests/generic/nonExistScript/generatedDiffs",
"report": "./e2eTests/generic/nonExistScript/reports",
"remoteBucketName": "aye-spy",
"remoteRegion": "eu-west-1",
"scenarios": [
{
"url": "http://ayespy_report:4000",
"label": "image",
"onReadyScript": "./nonExistScript.js",
"viewports": [{"height": 2400, "width": 1024, "label": "large"}]
}]
}
59 changes: 59 additions & 0 deletions src/scenarioValidator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* globals expect */
import scenarioValidator from './scenarioValidator';

describe('Validate Scenario', () => {
it('Valid Scenario', () => {
const scenario = {
url: 'http://lol.co.uk/',
label: 'scenario-valid-viewport',
viewports: [{ width: 1024, height: 800, label: 'large' }]
};

expect(() => scenarioValidator(scenario)).not.toThrow();
});
it('Scenario missing height', () => {
const scenario = {
url: 'http://lol.co.uk/',
label: 'scenario-height-missing',
viewports: [{ width: 1024, label: 'large' }]
};
expect(() => scenarioValidator(scenario)).toThrow(
'scenario-height-missing has no height set'
lukasr22 marked this conversation as resolved.
Show resolved Hide resolved
);
});

it('Scenario missing width', () => {
const scenario = {
url: 'http://lol.co.uk/',
label: 'scenario-width-missing',
viewports: [{ height: 1024, label: 'large' }]
};

expect(() => scenarioValidator(scenario)).toThrow(
'scenario-width-missing has no width set'
);
});

it('Scenario missing label', () => {
const scenario = {
url: 'http://lol.co.uk/',
label: 'scenario-label-missing',
viewports: [{ height: 1024, width: 800 }]
};

expect(() => scenarioValidator(scenario)).toThrow(
'scenario-label-missing has no label set'
);
});

it('Scenario missing viewport', () => {
const scenario = {
url: 'http://lol.co.uk/',
label: 'scenario-viewport-missing'
};

expect(() => scenarioValidator(scenario)).toThrow(
'scenario-viewport-missing has no viewports array defined'
);
});
});
Loading