-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackstop.js
More file actions
53 lines (45 loc) · 1.33 KB
/
backstop.js
File metadata and controls
53 lines (45 loc) · 1.33 KB
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
const glob = require('glob-promise');
const backstop = require('backstopjs');
var args = require('minimist')(process.argv.slice(2));
const componentPath = './test/components';
const config = require('./_config');
const server = require('./bin/server');
server.start();
const projectConfig = (scenarios) => {
return require("./test/backstop.config.js")({"scenarios": scenarios});
};
let commandToRun = "";
let singleRun = args.singleRun;
if( args.reference ) {
commandToRun = "reference";
}
if( args.test ) {
commandToRun = "test";
}
if( args.openReport ) {
commandToRun = "openReport";
}
function getScenariosForProject(projectPath) {
return new Promise((resolve) => {
var promises = [];
glob(projectPath + '/**/*.vis.js').then((files) => {
files.forEach((element) => {
var scenario = require(element);
promises.push(scenario.config(config.host, config.port));
});
resolve(promises);
});
});
}
getScenariosForProject(componentPath).then((scenarios) => {
if( "" !== commandToRun ) {
backstop(commandToRun, { config: projectConfig(scenarios) }).then(
() => {
if (singleRun) {
server.stop();
}
}, () => {
server.stop();
});
}
});