forked from pixel-point/kube-forwarder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress-runner.js
49 lines (38 loc) · 1.05 KB
/
cypress-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
const { spawn } = require('child_process')
const { startWeb } = require('./web-runner')
function runCypress(args) {
return new Promise((resolve, reject) => {
const cypressProcess = spawn(`node_modules/.bin/cypress`, ['run', ...args], {
stdio: [process.stdin, process.stdout, process.stderr]
})
console.log('Cypress is spawned.')
cypressProcess.on('close', (code) => {
code === 0 ? resolve() : reject(new Error(`Cypress exited with code: ${code}`))
})
cypressProcess.on('error', (error) => {
reject(error)
})
cypressProcess.on('disconnect', () => {
reject(new Error('Cypress was disconnected'))
})
})
}
async function init() {
const args = process.argv.slice(2)
const webpackServer = await startWeb()
console.log('Renderer is started at 9081')
let error
try {
await runCypress(args)
} catch(err) {
error = err
}
console.log('Cypress completed.')
webpackServer.close()
console.log('Renderer stopped.')
if (error) {
console.error(error)
process.exit(1)
}
}
init()