This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathbackstop-settings.js
129 lines (119 loc) · 3.5 KB
/
backstop-settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// How to use
/*
step # 1
Please update this with the Heroku deployment id or your pull request ID
*/
var deploymentId = "1107";
/*
Step # 2
Run the following commands in your terminal based on your prefered test cases bleow
------------------------------------------
To test default setting (only Homepage)
------------------------------------------
1. run command on all devices - this prepares everything to initiate the test
backstop reference --configPath=backstop-settings.js
2. initiates the test and compares to production
backstop test --configPath=backstop-settings.js
-------------------------------------------------------------------------------
To test specific pages of your choice, add the page name, followed by a comma
-------------------------------------------------------------------------------
backstop reference --configPath=backstop-settings.js --paths=/,/partnerships
backstop test --configPath=backstop-settings.js --paths=/,/partnerships
-------------------------------------
To test the entire site all at once
-------------------------------------
backstop reference --configPath=backstop-settings.js --pathfile=paths
backstop test --configPath=backstop-settings.js --pathfile=paths
*/
/*
That's all! Now watch your browser do some magic :)
*/
var arguments = require('minimist')(process.argv.slice(2)); // grabs the process arguments
var defaultPaths = ['/']; // By default is just checks the homepage
var scenarios = []; // The array that'll have the pages to test
/*
Work out the environments that are being compared
*/
// The host to test
// TODO:
// Pass the deplyment ID
// Pass the french array path list
if (!arguments.testhost) {
//added temporairly for testing
arguments.testhost = "https://digital-canada-ca-pr-"+ deploymentId +".herokuapp.com"; // Default test host
}
// The host to reference
if (!arguments.refhost) {
arguments.refhost = "https://digital.canada.ca"; // Default test host
}
/*
Work out which paths to use, either a supplied array, an array from a file, or the defaults
*/
if (arguments.paths) {
pathString = arguments.paths;
var paths = pathString.split(',');
} else if (arguments.pathfile) {
var pathConfig = require('./'+arguments.pathfile+'.js');
var paths = pathConfig.array;
} else {
var paths = defaultPaths; // keep with the default of just the homepage
}
for (var k = 0; k < paths.length; k++) {
scenarios.push({
"label": paths[k],
"referenceUrl": arguments.refhost+paths[k],
"url": arguments.testhost+paths[k],
"hideSelectors": [],
"removeSelectors": [],
"selectors": [],
"readyEvent": null,
"delay": 500,
"misMatchThreshold" : 0.1
});
}
// Configuration
module.exports =
{
"id": "prod_test",
"viewports": [
{
"name": "small",
"width": 320,
"height": 480
},
{
"name": "mediumish",
"width": 568,
"height": 760
},
{
"name": "medium",
"width": 768,
"height": 1024
},
{
"name": "large",
"width": 1024,
"height": 768
},
{
"name": "xlarge",
"width": 1440,
"height": 900
}
],
"scenarios":
scenarios
,
"paths": {
"bitmaps_reference": "backstop_data/bitmaps_reference",
"bitmaps_test": "backstop_data/bitmaps_test",
"casper_scripts": "backstop_data/casper_scripts",
"html_report": "backstop_data/html_report",
"ci_report": "backstop_data/ci_report"
},
"casperFlags": [],
"engine": "puppeteer",
"report": ["browser"],
"debug": true
};