forked from tnicola/cypress-parallel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.js
111 lines (105 loc) · 2.66 KB
/
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
const yargs = require('yargs');
const argv = yargs
.parserConfiguration({ 'duplicate-arguments-array': false })
.option('script', {
alias: 's',
type: 'string',
description: 'Your npm Cypress command'
})
.option('threads', {
alias: 't',
type: 'number',
description: 'Number of threads'
})
.option('verbose', {
alias: 'v',
type: 'boolean',
description: 'Execute with verbose logging'
})
.option('bail', {
alias: 'b',
type: 'boolean',
description: 'Exit on first suite finishing with errors'
})
.option('specsDir', {
alias: 'd',
type: 'string',
description: 'Cypress specs directory'
})
.option('args', {
alias: 'a',
type: 'string',
description: 'Your npm Cypress command arguments'
})
.option('reporter', {
alias: 'r',
type: 'string',
description: 'Reporter to pass to Cypress'
})
.option('reporterModulePath', {
alias: 'n',
type: 'string',
description: 'Reporter module path'
})
.option('reporterOptions', {
alias: 'o',
type: 'string',
description: 'Reporter options'
})
.option('reporterOptionsPath', {
alias: 'p',
type: 'string',
description: 'Reporter options path'
})
.option('strictMode', {
alias: 'm',
type: 'boolean',
default: true,
description: 'Strict mode checks'
})
.option('weightsJson', {
alias: 'w',
type: 'string',
description: 'Parallel weights json file'
})
.option('runnerResults', {
alias: 'x',
type: 'string',
description: 'Path where cypress results will be located'
}).argv;
if (!argv.script) {
throw new Error('Expected command, e.g.: cypress-parallel-openx <cypress-script>');
}
const COLORS = [
'\x1b[32m',
'\x1b[36m',
'\x1b[29m',
'\x1b[33m',
'\x1b[37m',
'\x1b[38m',
'\x1b[39m',
'\x1b[40m'
];
const settings = {
threadCount: argv.threads ? argv.threads : 2,
testSuitesPath: argv.specsDir ? argv.specsDir : 'cypress/integration',
shouldBail: argv.bail ? argv.bail : false,
isVerbose: argv.verbose ? argv.verbose : false,
weightsJSON: argv.weightsJson ? argv.weightsJson : 'cypress/parallel-weights.json',
defaultWeight: 1,
reporter: argv.reporter,
reporterModulePath: argv.reporterModulePath
? argv.reporterModulePath
: 'cypress-multi-reporters',
reporterOptions: argv.reporterOptions,
reporterOptionsPath: argv.reporterOptionsPath,
script: argv.script,
strictMode: argv.strictMode,
scriptArguments: argv.args ? argv.args.split(' ') : [],
runnerResults: argv.runnerResults ? argv.runnerResults : 'runner-results',
};
process.env.CY_PARALLEL_SETTINGS = JSON.stringify(settings);
module.exports = {
settings,
COLORS
};