Skip to content

Commit 3a77286

Browse files
committed
backstop tests
1 parent 595f403 commit 3a77286

19 files changed

+136
-237
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
src/index.js
22
src/serviceWorker.js
3-
src/setupTests.js
43
build/
54
public/
5+
test/backstop_data

.eslintrc.json

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,5 @@
33
"parser": "babel-eslint",
44
"rules": {
55
"react/jsx-filename-extension": [1, { "extensions": [".js"] }]
6-
},
7-
"overrides": [
8-
{
9-
"files": [
10-
"**/*.test.js"
11-
],
12-
"env": {
13-
"jest": true
14-
},
15-
"plugins": ["jest"],
16-
"rules": {
17-
"jest/no-disabled-tests": "warn",
18-
"jest/no-focused-tests": "error",
19-
"jest/no-identical-title": "error",
20-
"jest/prefer-to-have-length": "warn",
21-
"jest/valid-expect": "error"
22-
},
23-
"globals": {
24-
"window": true
25-
}
26-
}
27-
]
6+
}
287
}

.github/workflows/deploy.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ jobs:
1818
- name: Install dependencies
1919
run: yarn install
2020

21-
# - name: Run tests
22-
# run: yarn test --coverage
23-
# env:
24-
# CI: true
21+
- name: Run tests
22+
run: yarn test
2523

2624
- name: Build GitHub
2725
run: yarn build

.github/workflows/test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ jobs:
2525
# - name: Audit dependencies
2626
# - run: yarn audit
2727

28-
# - name: Run tests
29-
# run: yarn test --coverage
30-
# env:
31-
# CI: true
28+
- name: Run tests
29+
run: yarn test
3230

3331
- name: Build
3432
run: yarn build

Dockerfile-test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM node:14.2.0
2+
3+
ADD . /app
4+
WORKDIR /app
5+
6+
RUN yarn install

docker-compose.test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3'
2+
services:
3+
test:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile-test
7+
volumes:
8+
- .:/app
9+
command: yarn start
10+
ports:
11+
- 3000:3000
12+
stdin_open: true # https://github.com/facebook/create-react-app/issues/8688
13+
backstop:
14+
image: backstopjs/backstopjs:5.0.1
15+
volumes:
16+
- ./test:/src
17+
depends_on:
18+
- test

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"private": true,
55
"homepage": "https://perseids-project.github.io/treebank-wordcloud/",
66
"dependencies": {
7-
"@testing-library/jest-dom": "^5.11.3",
8-
"@testing-library/react": "^10.4.8",
9-
"@testing-library/user-event": "^12.1.1",
107
"bootstrap": "^4.5.2",
118
"cross-fetch": "^3.0.5",
129
"eslint-config-airbnb": "^18.2.0",
@@ -18,7 +15,6 @@
1815
"react-dom": "^16.13.1",
1916
"react-router-dom": "^5.2.0",
2017
"react-scripts": "3.4.3",
21-
"react-test-renderer": "^16.13.1",
2218
"react-wordcloud": "^1.2.7",
2319
"typeface-arimo": "^0.0.72",
2420
"typeface-tinos": "^0.0.72"
@@ -32,7 +28,8 @@
3228
"cleanup": "rm -rf node_modules/gh-pages/.cache",
3329
"start": "react-scripts start",
3430
"build": "react-scripts build && cp build/index.html build/404.html",
35-
"test": "react-scripts test",
31+
"test": "bash test/test.sh",
32+
"approve-changes": "bash test/approve-changes.sh",
3633
"lint": "eslint --ext=js --ext=jsx .",
3734
"eject": "react-scripts eject"
3835
},

src/setupTests.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/approve-changes.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker-compose -f docker-compose.test.yml run backstop approve

test/backstop.json

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"id": "test",
3+
"viewports": [
4+
{
5+
"label": "phone",
6+
"width": 320,
7+
"height": 480
8+
},
9+
{
10+
"label": "tablet",
11+
"width": 1024,
12+
"height": 768
13+
}
14+
],
15+
"onBeforeScript": "puppet/onBefore.js",
16+
"onReadyScript": "puppet/onReady.js",
17+
"scenarios": [
18+
{
19+
"label": "Home page renders",
20+
"cookiePath": "backstop_data/engine_scripts/cookies.json",
21+
"url": "http://test:3000/",
22+
"referenceUrl": "",
23+
"readyEvent": "",
24+
"readySelector": "",
25+
"delay": 2000,
26+
"hideSelectors": [],
27+
"removeSelectors": [],
28+
"hoverSelector": "",
29+
"clickSelector": "",
30+
"postInteractionWait": 0,
31+
"selectors": [],
32+
"selectorExpansion": true,
33+
"expect": 0,
34+
"misMatchThreshold" : 0.1,
35+
"requireSameDimensions": true
36+
},
37+
{
38+
"label": "Word cloud renders",
39+
"cookiePath": "backstop_data/engine_scripts/cookies.json",
40+
"url": "http://test:3000/aHR0cHM6Ly9wZXJzZWlkcy1wdWJsaWNhdGlvbnMuZ2l0aHViLmlvL2dvcm1hbi10cmVlcy94bWwvaGR0LTEtMS0xOS1idTMueG1s",
41+
"referenceUrl": "",
42+
"readyEvent": "",
43+
"readySelector": "",
44+
"delay": 2000,
45+
"hideSelectors": [],
46+
"removeSelectors": [],
47+
"hoverSelector": "",
48+
"clickSelector": "",
49+
"postInteractionWait": 0,
50+
"selectors": [],
51+
"selectorExpansion": true,
52+
"expect": 0,
53+
"misMatchThreshold" : 0.1,
54+
"requireSameDimensions": true
55+
},
56+
{
57+
"label": "Word cloud renders given an index",
58+
"cookiePath": "backstop_data/engine_scripts/cookies.json",
59+
"url": "http://test:3000/aHR0cHM6Ly9wZXJzZWlkcy1wdWJsaWNhdGlvbnMuZ2l0aHViLmlvL2dvcm1hbi10cmVlcy94bWwvaGR0LTEtMS0xOS1idTMueG1s/18",
60+
"referenceUrl": "",
61+
"readyEvent": "",
62+
"readySelector": "",
63+
"delay": 2000,
64+
"hideSelectors": [],
65+
"removeSelectors": [],
66+
"hoverSelector": "",
67+
"clickSelector": "",
68+
"postInteractionWait": 0,
69+
"selectors": [],
70+
"selectorExpansion": true,
71+
"expect": 0,
72+
"misMatchThreshold" : 0.1,
73+
"requireSameDimensions": true
74+
}
75+
],
76+
"paths": {
77+
"bitmaps_reference": "backstop_data/bitmaps_reference",
78+
"bitmaps_test": "backstop_data/bitmaps_test",
79+
"engine_scripts": "backstop_data/engine_scripts",
80+
"html_report": "backstop_data/html_report",
81+
"ci_report": "backstop_data/ci_report"
82+
},
83+
"report": ["browser"],
84+
"engine": "puppeteer",
85+
"engineOptions": {
86+
"args": ["--no-sandbox"]
87+
},
88+
"asyncCaptureLimit": 5,
89+
"asyncCompareLimit": 50,
90+
"debug": false,
91+
"debugWindow": false
92+
}

0 commit comments

Comments
 (0)