UNPKG

1.24 kBJavaScriptView Raw
1const { UTRError } = require('./error')
2const { $valueSources } = require('./symbols')
3
4function check (job, allowed, forbidden) {
5 const valueSources = job[$valueSources]
6 const incompatible = Object.keys(valueSources).filter(option => {
7 const source = valueSources[option]
8 return source === 'cli' && !option.startsWith('debug') &&
9 (
10 (allowed && !allowed.includes(option)) ||
11 (forbidden && forbidden.includes(option))
12 )
13 })
14 if (incompatible.length) {
15 throw UTRError.MODE_INCOMPATIBLE_OPTION(incompatible.join(','))
16 }
17}
18
19function buildAndCheckMode (job) {
20 if (job.capabilities) {
21 check(job, [
22 'capabilities',
23 'cwd',
24 'port',
25 'logServer',
26 'browser',
27 'parallel',
28 'reportDir',
29 'pageTimeout',
30 'browserCloseTimeout',
31 'failFast',
32 'keepAlive'
33 ])
34 return 'capabilities'
35 }
36 if (job.url && job.url.length) {
37 check(job, undefined, [
38 'ui5',
39 'libs',
40 'mappings',
41 'cache',
42 'watch',
43 'testsuite'
44 ])
45 return 'url'
46 }
47 check(job, undefined, [
48 'coverageProxy',
49 'coverageProxyInclude',
50 'coverageProxyExclude'
51 ])
52 return 'legacy'
53}
54
55module.exports = {
56 buildAndCheckMode
57}