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

Add visual regression testing using Applitools Eyes #1597

Closed
Closed
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
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
- run:
name: Tests
command: yarn run test:jest
- run:
name: Visual Tests
command: yarn run test:visual
- store_artifacts:
path: build

Expand Down
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test:
override:
- yarn run test:cli
- yarn run test:jest
- yarn run test:visual
general:
artifacts:
- build
4 changes: 4 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"eyesTimeout": 1200000,
"video": false
}
11 changes: 11 additions & 0 deletions cypress/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"env": {
"browser": true,
"node": true,
"mocha": true
},
"globals": {
"cy": true
},
"plugins": ["mocha"]
}
43 changes: 43 additions & 0 deletions cypress/integration/visual-regression-smoke-tests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
describe('Visual Regression - Smoke Tests', () => {
beforeEach(() => {
cy.eyesOpen({
appName: 'Auth0 Lock',
testName: 'Visual Regression - Smoke Tests',
browser: [
{
name: 'chrome',
width: 1280,
height: 800
},
{
name: 'firefox',
width: 1280,
height: 800
}
]
});
});

afterEach(() => {
cy.eyesClose();
});

it('Should render each lock style correctly', () => {
cy.visit(`http://localhost:8080/support/design/`);
//Delay DOM grab till locks render
cy.wait(2000);

cy.get('.lock-container').then($nodes => {
for (let i = 0, l = $nodes.length; i < l; i++) {
cy.eyesCheckWindow({
sizeMode: 'selector',
selector: {
type: 'xpath',
selector: `//*[@id='${$nodes.eq(i).get(0).id}'][1]`
},
tag: $nodes.eq(i).get(0).id
});
}
});
});
});
19 changes: 19 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};

require('@applitools/eyes.cypress')(module);
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
26 changes: 26 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')

Cypress.Screenshot.defaults({
screenshotOnRunFailure: false
});

import '@applitools/eyes.cypress/commands';
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
"test:es-check": "es-check es5 'build/*.js'",
"publish:cdn": "ccu",
"release": "scripts/release.sh",
"i18n:translate": "grunt dist && node scripts/complete-translations.js"
"i18n:translate": "grunt dist && node scripts/complete-translations.js",
"cypress:run": "cross-env APPLITOOLS_CONCURRENCY=100 cypress run",
"test:visual": "concurrently -k -s first \"npm:design\" \"npm:cypress:run\""
},
"devDependencies": {
"@applitools/eyes.cypress": "^3.3.23",
"babel-core": "^6.17.0",
"babel-eslint": "^7.2.2",
"babel-loader": "^6.2.5",
Expand All @@ -46,8 +49,10 @@
"babelify": "^7.2.0",
"bump-version": "^0.5.0",
"component-cdn-uploader": "auth0/component-cdn-uploader#v1.3.0",
"concurrently": "^4.1.0",
"cross-env": "^3.1.4",
"css-loader": "^0.26.1",
"cypress": "^3.1.4",
"dotenv": "^4.0.0",
"enzyme": "^3.1.0",
"enzyme-adapter-react-15": "^1.0.1",
Expand Down Expand Up @@ -118,14 +123,16 @@
"<rootDir>/test/",
"<rootDir>/lib/",
"<rootDir>/src/__tests__/testUtils.js",
"<rootDir>/src/__tests__/setup-tests.js"
"<rootDir>/src/__tests__/setup-tests.js",
"<rootDir>/cypress/"
],
"testPathIgnorePatterns": [
"/node_modules/",
"<rootDir>/test/",
"<rootDir>/lib/",
"<rootDir>/src/__tests__/testUtils.js",
"<rootDir>/src/__tests__/setup-tests.js"
"<rootDir>/src/__tests__/setup-tests.js",
"<rootDir>/cypress/"
],
"coverageReporters": ["lcov", "text-summary"]
},
Expand Down
Loading