ui5-test-runner
Version:
Standalone test runner for UI5
66 lines (62 loc) • 1.4 kB
JavaScript
const { UTRError } = require('./error')
const { $valueSources } = require('./symbols')
function check (job, allowed, forbidden) {
const valueSources = job[$valueSources]
const incompatible = Object.keys(valueSources).filter(option => {
const source = valueSources[option]
return source === 'cli' && !option.startsWith('debug') &&
(
(allowed && !allowed.includes(option)) ||
(forbidden && forbidden.includes(option))
)
})
if (incompatible.length) {
throw UTRError.MODE_INCOMPATIBLE_OPTION(incompatible.join(','))
}
}
function buildAndCheckMode (job) {
if (job.batch) {
return 'batch'
}
if (job.capabilities) {
check(job, [
'capabilities',
'cwd',
'port',
'logServer',
'browser',
'parallel',
'reportDir',
'pageTimeout',
'browserCloseTimeout',
'browserRetry',
'failFast',
'keepAlive',
'alternateNpmPath',
'outputInterval',
'screenshotTimeout',
'config',
'batchMode',
'batchId',
'batchLabel',
'ci',
'if'
])
return 'capabilities'
}
if (job.url && job.url.length) {
check(job, undefined, [
'testsuite'
])
return 'url'
}
check(job, undefined, [
'coverageProxy',
'coverageProxyInclude',
'coverageProxyExclude'
])
return 'legacy'
}
module.exports = {
buildAndCheckMode
}