-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackstop_config.js
113 lines (102 loc) · 3.12 KB
/
backstop_config.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
const fs = require("fs");
const path = require("path");
const testsFolder = (__dirname + '/tests');
const arguements = require('minimist')(process.argv.slice(2));
let scenarios = [];
let tests = [];
//TODO: Add staging link for testing (don't need one for reference)
// The default host to test
if (!arguements.testHost) {
arguements.testHost = "https://elephant.is";
}
// The default host to reference
if (!arguements.referenceHost) {
arguements.referenceHost = "https://elephant.is";
}
// Default Settings - used when there are no configuration set in the 'tests' folders.
const defaultTest = {
"label": "",
"url": arguements.testHost + '/',
"referenceUrl": arguements.referenceHost + '/',
"selectors": [],
"readyEvent": null,
"delay": 3000,
"misMatchThreshold": 0.9,
"onBeforeScript": "",
"onReadyScript": "puppet/onReady.js",
"cookiePath": ""
};
// Finds all the test cases needed to run (from both paths_config.js and scenarios_config.js)
// TODO: to return error when no test cases are found (current error returns undefined)
const testFiles = fs.readdirSync(testsFolder);
testFiles.forEach(entity => {
const filePath = `${testsFolder}/${entity}`;
if (path.extname(filePath) === '.js') {
const testList = require(filePath).scenarios;
testList.forEach((scenario) => {
tests.push(scenario);
});
};
});
// if no file has been found, run the default configuration
if (tests.length == 0){
tests = [
{
"label": "default"
}
];
}
function cloneObject(testObj) {
return (JSON.parse(JSON.stringify(testObj)));
}
// For each test case, generate the scenario
tests.forEach(test => {
let scenario = new Object();
scenario = Object.assign((defaultTest), test);
// TODO: remove all previous instances of selectors used (currently its being carried over to the next object)
if (scenario.relativeUrl) {
scenario.url = arguements.testHost + scenario.relativeUrl;
scenario.referenceUrl = arguements.referenceHost + scenario.relativeUrl;
delete scenario.relativeUrl;
}
scenarios.push(cloneObject(scenario));
});
console.log (scenarios);
module.exports = {
"id": "prod_test",
"viewports": [
{
"name": "desktop",
"width": 1440,
"height": 2560
},
{
"name": "tablet",
"width": 768,
"height": 1024
},
{
"name": "phone",
"width": 360,
"height": 780
}
],
"scenarios": scenarios,
"paths": {
"bitmaps_reference": "backstop_data/bitmaps_reference",
"bitmaps_test": "backstop_data/bitmaps_test",
"engine_scripts": "backstop_data/engine_scripts",
"html_report": "backstop_data/html_report",
"ci_report": "backstop_data/ci_report"
},
"report": ["browser"],
"engine": "puppeteer",
"engineOptions": {
"args": ["--no-sandbox", "--disable-setuid-sandbox"],
"ignoreHTTPSErrors": true
},
"asyncCaptureLimit": 9,
"asyncCompareLimit": 50,
"debug": false,
"debugWindow": false
};