Skip to content

Commit

Permalink
PP-4294 Add "cypress" package
Browse files Browse the repository at this point in the history
PP-4294 Cypress.io initial directories and files

PP-4294 Add base Cypress.io test for non payment flow homepage
  • Loading branch information
DanailMinchev authored and Mark Bridgett committed Nov 1, 2018
1 parent c7f5bd7 commit 4044c64
Show file tree
Hide file tree
Showing 18 changed files with 4,205 additions and 3,200 deletions.
23 changes: 23 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ pipeline {
}
}
}
stage('Browser Tests') {
steps {
cypress('frontend')
}
}
stage('Contract Tests') {
steps {
script {
env.PACT_TAG = gitBranchName()
}
ws('contract-tests-wp') {
runPactProviderTests("pay-adminusers", "${env.PACT_TAG}")
runPactProviderTests("pay-connector", "${env.PACT_TAG}")
}
}
post {
always {
ws('contract-tests-wp') {
deleteDir()
}
}
}
}
stage('Tests') {
failFast true
parallel {
Expand Down
14 changes: 14 additions & 0 deletions bin/publish-pacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node
let pact = require('@pact-foundation/pact-node')
let opts = {
pactFilesOrDirs: [`${__dirname}/../pacts/`],
pactBroker: process.env.PACT_BROKER_URL,
consumerVersion: process.env.PACT_CONSUMER_VERSION,
pactBrokerUsername: process.env.PACT_BROKER_USERNAME,
pactBrokerPassword: process.env.PACT_BROKER_PASSWORD,
tags: process.env.PACT_CONSUMER_TAG
}

pact.publishPacts(opts).then(function () {
console.log('>> Pact files have been published')
})
14 changes: 14 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"baseUrl": "http://localhost:3000",
"viewportHeight": 800,
"viewportWidth": 1280,
"env": {
"TEST_SESSION_ENCRYPTION_KEY": "naskjwefvwei72rjkwfmjwfi72rfkjwefmjwefiuwefjkbwfiu24fmjbwfk"
},
"fileServerFolder": "./test/cypress",
"integrationFolder": "./test/cypress/integration",
"pluginsFile": "./test/cypress/plugins",
"screenshotsFolder": "./test/cypress/screenshots",
"supportFile": false,
"videosFolder": "./test/cypress/videos"
}
Empty file added cypress/fixtures/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Empty file added cypress/integration/.gitkeep
Empty file.
Empty file added cypress/plugins/.gitkeep
Empty file.
17 changes: 17 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -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
}
Empty file added cypress/support/.gitkeep
Empty file.
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) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -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')
2 changes: 1 addition & 1 deletion docker/build_and_test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ADD package-lock.json /tmp/package-lock.json
RUN cd /tmp && npm install
WORKDIR /app
ENV LD_LIBRARY_PATH /app/node_modules/appmetrics
CMD ./docker/build_and_test.sh
CMD ./docker/build_and_test.sh
21 changes: 15 additions & 6 deletions docker/build_and_test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/usr/bin/env bash

rm -rf node_modules &&\
ln -s /tmp/node_modules /app/node_modules &&\
set -ueo pipefail
rm -rf node_modules
cp -R /tmp/node_modules /app/node_modules
npm run compile &&\
npm run lint &&\
npm test -- --forbid-only --forbid-pending &&\
rm -rf node_modules
npm run lint
npm test -- --forbid-only --forbid-pending
findpacts=$(ls -1 ./pacts | wc -l)
if [ $findpacts -gt 0 ]
then
echo "Got pact files"
# prevent publish of any pacts with 'to-be' in their name
for i in ./pacts/*-to-be-*.json; do mv "$i" "${i%.json}.ignore"; done
npm run publish-pacts
else
echo "No pact files found"
fi
Loading

0 comments on commit 4044c64

Please sign in to comment.