Skip to content

Commit 5c38af2

Browse files
committed
Add default local backstop.json file and improve actions tests
1 parent df55342 commit 5c38af2

File tree

6 files changed

+80
-10
lines changed

6 files changed

+80
-10
lines changed

backstopjsFiles/local/backstop.json

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"id": "backstop_default",
3+
"viewports": [
4+
{
5+
"label": "phone",
6+
"width": 375,
7+
"height": 480
8+
},
9+
{
10+
"label": "tablet",
11+
"width": 1024,
12+
"height": 768
13+
},
14+
{
15+
"label": "Desktop",
16+
"width": 1920,
17+
"height": 1080
18+
}
19+
],
20+
"onBeforeScript": "puppet/onBefore.js",
21+
"onReadyScript": "puppet/onReady.js",
22+
"scenarios": [
23+
{
24+
"label": "Homepage",
25+
"url": "http://web/",
26+
"selectorExpansion": true,
27+
"readySelector": "body",
28+
"misMatchThreshold" : 0.1
29+
}
30+
],
31+
"paths": {
32+
"bitmaps_reference": "bitmaps_reference",
33+
"bitmaps_test": "bitmaps_test",
34+
"engine_scripts": "engine_scripts",
35+
"html_report": "html_report",
36+
"ci_report": "ci_report"
37+
},
38+
"report": [
39+
"browser",
40+
"CI"
41+
],
42+
"ci": {
43+
"format" : "junit" ,
44+
"testSuiteName" : "backstopJS"
45+
},
46+
"engine": "puppeteer",
47+
"engineOptions": {
48+
"ignoreHTTPSErrors": true,
49+
"slowMo": 500,
50+
"args": [
51+
"--no-sandbox",
52+
"--disable-setuid-sandbox",
53+
"--disable-gpu",
54+
"--force-device-scale-factor=1",
55+
"--disable-infobars=true",
56+
"--hide-scrollbars"
57+
]
58+
59+
},
60+
"asyncCaptureLimit": 10,
61+
"asyncCompareLimit": 30,
62+
"debug": false,
63+
"debugWindow": false
64+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module.exports = async (page, scenario, vp) => {
2+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = async (page, scenario, vp) => {
2+
3+
};

install.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
name: backstopjs
22

3-
pre_install_actions:
4-
- test -d ${DDEV_APPROOT}/tests/backstopjs/local || mkdir -p ${DDEV_APPROOT}/tests/backstopjs/local
5-
- test -f "${DDEV_APPROOT}/tests/backstopjs/local/.gitignore" || printf "## ddev-generated\n**/bitmaps_test\n**/html_report\n" > ${DDEV_APPROOT}/tests/backstopjs/local/.gitignore
6-
- grep -q "## ddev-generated" ${DDEV_APPROOT}/tests/backstopjs/local/.gitignore && printf "## ddev-generated\n**/bitmaps_test\n**/html_report\n" > ${DDEV_APPROOT}/tests/backstopjs/local/.gitignore
7-
83
project_files:
94
- docker-compose.backstopjs.yaml
105
- backstopjsBuild/
6+
- backstopjsFiles
117
- commands/
128

139
post_install_actions:
10+
- test -d ../tests/backstopjs || mkdir -p ../tests/backstopjs
11+
- test -d ../tests/backstopjs/local || mv backstopjsFiles/local ../tests/backstopjs/
1412
- echo "Install finished. Please restart ddev with 'ddev restart'"
1513
- echo "After that create your backstop config, e.g. run ddev backstop init."
1614
- echo "If you need to set a custom backstopjs version, add an .env file inside .ddev folder with variable BACKSTOPJS_VERSION set"

tests/test.bats

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ teardown() {
2626
ddev restart
2727

2828
# backstop is installed and can show its version
29-
ddev backstopjs version | grep 'Command "version" successfully executed'
29+
ddev backstopjs local version | grep 'Command "version" successfully executed'
30+
31+
# Test should fail because there is no reference bitmaps
32+
ddev backstopjs local test | grep 'Command "version" successfully executed' || true
33+
# Create reference bitmaps
34+
ddev backstopjs local reference
35+
# Test should pass because there is a reference bitmaps
36+
ddev backstopjs local test
3037

31-
# openReport and remote commands show an error message
32-
set +o pipefail
33-
ddev backstopjs openReport | grep -q 'This does not work for backstop in ddev'
34-
ddev backstopjs remote | grep -q 'This does not work for backstop in ddev'
3538
}
3639

3740
#@test "install from release" {

0 commit comments

Comments
 (0)