Add Cypress visual testing (#2471)
* add the travis-encrypted PERCY_TOKEN value pair, and a database bootstrap as part of the test setup
This commit is contained in:
Родитель
4ab2a99ca4
Коммит
54bc792de0
|
@ -112,3 +112,6 @@ network-api/networkapi/frontend/*
|
|||
|
||||
# PyCharm
|
||||
.idea/
|
||||
|
||||
# Cypress visual regression testing
|
||||
cypress/videos
|
||||
|
|
|
@ -14,10 +14,12 @@ install:
|
|||
- pipenv run python network-api/manage.py collectstatic --no-input
|
||||
before_script:
|
||||
- psql -c 'create database network;' -U postgres
|
||||
- ./release-steps.sh
|
||||
script:
|
||||
- npm test
|
||||
- pipenv run flake8 tasks.py network-api/
|
||||
- pipenv run coverage run --source './network-api/networkapi' network-api/manage.py test networkapi
|
||||
- npm run cypress
|
||||
after_success:
|
||||
- coveralls
|
||||
env:
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"baseUrl": "http://localhost:8000"
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
describe('Integration test with visual testing', () => {
|
||||
it('Loads the homepage', function() {
|
||||
|
||||
// Load the page or perform any other interactions with the app.
|
||||
cy.visit(`/`);
|
||||
|
||||
// Take a snapshot for visual diffing
|
||||
cy.percySnapshot();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
// ***********************************************************
|
||||
// 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
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// ***********************************************
|
||||
// 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) => { ... })
|
||||
|
||||
import '@percy/cypress';
|
|
@ -0,0 +1,20 @@
|
|||
// ***********************************************************
|
||||
// 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')
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -14,6 +14,8 @@
|
|||
"build:sass": "shx mkdir -p network-api/networkapi/frontend/_css && node-sass source/sass/main.scss network-api/networkapi/frontend/_css/main.compiled.css && node-sass source/sass/buyers-guide/bg-main.scss network-api/networkapi/frontend/_css/buyers-guide.compiled.css && npm run autoprefix",
|
||||
"build": "npm run build:common && npm run build:js",
|
||||
"build-uncompressed": "npm run build:common && npm run build:js-uncompressed",
|
||||
"cypress": "run-p --race server cypress:test",
|
||||
"cypress:test": "wait-on tcp:8000 && cypress run",
|
||||
"heroku-postbuild": "npm run build",
|
||||
"migrate": "pipenv run python network-api/manage.py migrate",
|
||||
"optimize:svg": "find source/images -type f -name '*.svg' -print0 | xargs -0 -n 1 -P 6 svgo --multipass --pretty --enable=removeTitle",
|
||||
|
@ -77,5 +79,10 @@
|
|||
},
|
||||
"engines": {
|
||||
"node": "^8.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@percy/cypress": "^0.2.3",
|
||||
"cypress": "^3.1.4",
|
||||
"wait-on": "^3.2.0"
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче