forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpause_headed_exit_spec.ts
79 lines (74 loc) · 2.11 KB
/
pause_headed_exit_spec.ts
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
import systemTests from '../lib/system-tests'
import childProcess from 'child_process'
describe('cy.pause() in run mode', () => {
systemTests.setup()
systemTests.it('pauses with --headed and --no-exit', {
spec: 'pause.cy.js',
config: {
env: {
'SHOULD_PAUSE': true,
},
},
snapshot: true,
headed: true,
noExit: true,
expectedExitCode: null,
onSpawn: (cp) => {
cp.stdout.on('data', (buf) => {
if (buf.toString().includes('not exiting due to options.exit being false')) {
// systemTests.it spawns a new node process which then spawns the actual cypress process
// Killing just the new node process doesn't kill the cypress process so we find it and kill it manually
childProcess.execSync(`kill $(pgrep -P ${cp.pid} | awk '{print $1}')`)
cp.kill()
}
})
},
})
systemTests.it('does not pause if headless', {
spec: 'pause.cy.js',
config: {
env: {
'SHOULD_PAUSE': false,
},
},
snapshot: true,
headed: false,
noExit: true,
expectedExitCode: null,
onSpawn: (cp) => {
cp.stdout.on('data', (buf) => {
if (buf.toString().includes('not exiting due to options.exit being false')) {
// systemTests.it spawns a new node process which then spawns the actual cypress process
// Killing just the new node process doesn't kill the cypress process so we find it and kill it manually
childProcess.execSync(`kill $(pgrep -P ${cp.pid} | awk '{print $1}')`)
cp.kill()
}
})
},
})
// TODO: fix this failing test in 10.0
systemTests.it.skip('does not pause without --no-exit', {
spec: 'pause.cy.js',
config: {
env: {
'SHOULD_PAUSE': false,
},
},
snapshot: true,
headed: true,
noExit: false,
expectedExitCode: 0,
})
systemTests.it('does not pause without --headed and --no-exit', {
spec: 'pause.cy.js',
config: {
env: {
'SHOULD_PAUSE': false,
},
},
snapshot: true,
headed: false,
noExit: false,
expectedExitCode: 0,
})
})