-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcy-runner.js
80 lines (64 loc) · 2.14 KB
/
cy-runner.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
const cfg = require('./node/config')
const system = require('./node/system')
const logger = require('./node/logger')
const cypress = require('./node/cypress')
const workspace = require('./node/workspace')
const { deprecated } = require('./node/deprecated')
const { report } = require('./node/report')
const { runTests } = require('./node/test')
const { issue } = require('./node/jira')
// Controls test state
const control = {
start: system.tick(),
timing: {},
specsFailed: [],
specsSkipped: [],
specsDisabled: [],
specsPassed: [],
runUrl: null,
}
async function main() {
// Init logger
logger.init()
// Welcome message
logger.msgSection('Cypress Runner')
// Read cy-runner.yml configuration
const config = await cfg.getConfig('cy-runner.yml')
// Init workspace set up
control.timing.initWorkspace = await workspace.init(config)
// Install apps
control.timing.installApps = await workspace.installApps(config)
// Uninstall apps
control.timing.uninstallApps = await workspace.uninstallApps(config)
// Link app
const link = await workspace.linkApp(config)
control.timing.linkApp = link.time
if (link.success) {
if (config.base.cypress.devMode) {
logger.msgWarn('Please, wait the flow when you finish')
logger.msgPad('This will ensure the release and teardown will run')
await cypress.open()
} else {
const call = await runTests(config)
control.timing.strategy = call.time
control.specsFailed = call.specsFailed
control.specsSkipped = call.specsSkipped
control.specsDisabled = call.specsDisabled
control.specsPassed = call.specsPassed
control.runUrl = call.runUrl
// Jira automation
if (config.base.jira.enabled && control.specsFailed?.length) {
await issue(config, control.specsFailed, control.runUrl)
}
}
}
// Teardown
if (link.subprocess) link.subprocess.kill('SIGHUP')
control.timing.teardown = await workspace.teardown(config, link.success)
// Report deprecated flags
await deprecated(config)
// Final Report
control.timing.total = system.tack(control.start)
await report(control, config)
}
main().then((r) => r)