-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackstop-settings.js
77 lines (68 loc) · 2.09 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
/*eslint camelcase: ["error", {properties: "never"}]*/
const glob = require('glob');
const pattern = './scenarios/**/*.js';
const configFiles = glob.sync(pattern);
const viewports = [
{ label: 'mobile', width: 320, height: 480 },
{ label: 'tablet', width: 768, height: 1024 },
{ label: 'desktop', width: 1024, height: 768 },
];
const darkModeScenarios = [];
const enhanceWithDarkMode = false;
const scenarios = configFiles.reduce((accumulator, filename) => {
const thisConfig = require(filename);
const labelPrefix = filename.split('/').slice(2).join('::').slice(0, -3);
thisConfig.forEach(scenario => {
scenario.label = [labelPrefix, scenario.url, scenario.label].join(' ').trimEnd();
if (scenario.viewports) {
scenario.viewports = viewports.filter(({ label }) =>
scenario.viewports.includes(label),
);
}
});
return accumulator.concat(thisConfig);
}, []);
function mergeDefaults(scenario) {
const defaults = {
readyTimeout: 8000, // Timeout for readyEvent and readySelector (default: 60000ms)
removeSelectors: ['#pDebug'],
selectors: ['main'],
};
scenario.url = 'http://localhost:9090' + scenario.url;
return Object.assign({}, defaults, scenario);
}
if (enhanceWithDarkMode) {
scenarios.forEach(scenario => {
if (scenario.label.indexOf('darkmode') === -1) {
// needs deep copy of scenario
const darkScenario = Object.assign({}, scenario);
darkScenario.label += ' darkmode';
darkScenario.onBeforeScript = 'prefers-color-scheme-dark.js';
darkModeScenarios.push(darkScenario);
}
});
}
module.exports = {
id: '',
viewports: viewports,
onBeforeScript: false,
onReadyScript: 'puppet/onReady.js',
scenarios: [...scenarios, ...darkModeScenarios].map(mergeDefaults),
paths: {
bitmaps_reference: 'data/references',
bitmaps_test: 'data/tests',
engine_scripts: 'engine_scripts',
html_report: 'data/html_report',
ci_report: 'data/ci_report',
},
report: ['browser'],
engine: 'puppeteer',
engineOptions: {
args: ['--no-sandbox'],
},
asyncCaptureLimit: 1, // default: 10
asyncCompareLimit: 50, // default: 50
debug: false,
debugWindow: false,
misMatchThreshold: 0,
};