-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackstop.js
executable file
·73 lines (63 loc) · 2.01 KB
/
backstop.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
var args = require('minimist')(process.argv.slice(2));
const scenarios = [];
let siteConfig = {};
if (!args.id) {
console.error('Error: No --id argument given.')
process.exit();
}
try {
config = './sites/' + args.id + '/config.js'
siteConfig = require(config);
} catch(err) {
console.error('Could not require config file ' + config);
process.exit();
}
const viewports = siteConfig.viewports ? siteConfig.viewports : require("./defaults/viewports");
const backstopConfig = siteConfig.backstopConfig ? siteConfig.backstopConfig : require("./defaults/backstopConfig");
const defaultScenario = siteConfig.defaultScenario ? siteConfig.defaultScenario : require("./defaults/scenario");
if(Object.keys(siteConfig.scenarios).length < 1) {
console.error("Error: No scenarios defined.")
process.exit();
}
if (args.url) {
url = args.url;
} else {
url = siteConfig.url;
}
if (!url) {
console.error('Error: missing url');
}
if (args.referenceUrl) {
referenceUrl = args.referenceUrl;
} else {
referenceUrl = siteConfig.referenceUrl;
}
if (!referenceUrl) {
console.error('Error: missing referenceUrl');
}
siteConfig.scenarios.map(scenario => {
scenarios.push({
...defaultScenario,
...{
...scenario,
...{
"label": scenario.label || scenario.url + (scenario.clickSelector || ""),
"url": url ? url + scenario.url : referenceUrl + scenario.url,
"referenceUrl": referenceUrl + (scenario.referenceUrl || scenario.url)
}
}
});
});
module.exports = {
...backstopConfig,
"id": args.id,
"viewports": viewports,
"scenarios": scenarios,
"paths": {
"bitmaps_reference": "backstop_data/" + args.id + "/bitmaps_reference",
"bitmaps_test": "backstop_data/" + args.id + "/bitmaps_test",
"engine_scripts": "engine_scripts",
"html_report": "backstop_data/" + args.id + "/html_report",
"ci_report": "backstop_data/" + args.id + "/ci_report"
},
};