Skip to content

Commit 4b326fb

Browse files
authored
Merge pull request #49 from mackbrowne/feature/visual-testing
add visual testing
2 parents 271f804 + cde0ccf commit 4b326fb

File tree

12 files changed

+1595
-97
lines changed

12 files changed

+1595
-97
lines changed

.circleci/config.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 2.1
2+
orbs:
3+
snyk: snyk/snyk@0.0.8
4+
cypress: cypress-io/cypress@1
5+
jobs:
6+
build:
7+
docker:
8+
- image: circleci/node:12.9.1-browsers
9+
10+
working_directory: ~/repo
11+
steps:
12+
- checkout
13+
14+
- restore_cache:
15+
name: Restore Yarn Package Cache
16+
keys:
17+
- yarn-packages-{{ checksum "yarn.lock" }}
18+
19+
- run:
20+
name: Install Dependencies
21+
command: yarn install --frozen-lockfile
22+
23+
- save_cache:
24+
name: Save Yarn Package Cache
25+
key: yarn-packages-{{ checksum "yarn.lock" }}
26+
paths:
27+
- ~/.cache/yarn
28+
29+
- run:
30+
name: Run Cypress Tests
31+
command: yarn ci
32+
33+
- snyk/scan:
34+
fail-on-issues: false
35+
monitor-on-build: false
36+
severity-threshold: high

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ yarn-error.log*
2424

2525
# Firebase
2626
.firebase/
27-
firebase-debug.log*
27+
firebase-debug.log*
28+
29+
# Cypress
30+
cypress/videos

cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"projectId": "xp8wm7"
3+
}

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable no-undef */
2+
/// <reference types="cypress" />
3+
4+
context('Example', () => {
5+
beforeEach(() => {
6+
cy.visit('http://localhost:3000')
7+
})
8+
9+
// https://on.cypress.io/interacting-with-elements
10+
11+
it('Test', () => {
12+
cy.get('body').snapshot();
13+
cy.percySnapshot()
14+
})
15+
})

cypress/plugins/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************************
3+
// This example plugins/index.js can be used to load plugins
4+
//
5+
// You can change the location of this file or turn off loading
6+
// the plugins file with the 'pluginsFile' configuration option.
7+
//
8+
// You can read more here:
9+
// https://on.cypress.io/plugins-guide
10+
// ***********************************************************
11+
12+
// This function is called when a project is opened or re-opened (e.g. due to
13+
// the project's config changing)
14+
15+
let percyHealthCheck = require('@percy/cypress/task')
16+
/**
17+
* @type {Cypress.PluginConfig}
18+
*/
19+
module.exports = (on, config) => {
20+
// `on` is used to hook into various events Cypress emits
21+
// `config` is the resolved Cypress config
22+
on("task", percyHealthCheck);
23+
}
24+

cypress/support/commands.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

cypress/support/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
import '@percy/cypress';
17+
import snapshots from '@cypress/snapshot';
18+
// Import commands.js using ES2015 syntax:
19+
import './commands';
20+
21+
snapshots.register();
22+
23+
// Alternatively you can use CommonJS syntax:
24+
// require('./commands')

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"build": "react-scripts build",
88
"print-pdf": "chrome-headless-render-pdf --include-background --url=http://localhost:3000 --pdf=public/resume.pdf --url=http://localhost:3000 --pdf=public/MackenzieBrowneResume.pdf",
99
"deploy": "firebase deploy",
10-
"test": "react-scripts test",
10+
"test": "concurrently \"yarn start\" \"cypress\"",
11+
"test:ci": "percy exec -- cypress run --record",
12+
"ci": "start-server-and-test start http://localhost:3000 test:ci",
1113
"eject": "react-scripts eject"
1214
},
1315
"dependencies": {
@@ -63,5 +65,12 @@
6365
"hooks": {
6466
"pre-commit": "lint-staged"
6567
}
68+
},
69+
"devDependencies": {
70+
"@cypress/snapshot": "^2.1.7",
71+
"@percy/cypress": "^2.3.1",
72+
"concurrently": "^5.2.0",
73+
"cypress": "^4.5.0",
74+
"start-server-and-test": "^1.11.0"
6675
}
6776
}

snapshots.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)