Skip to content

Commit 6934c03

Browse files
davidmunechikaemilyrohrboughflotwig
authored
fix(regression): cy.pause() should not be ignored with cypress run --headed --no-exit (#20877)
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com> Co-authored-by: Zach Bloomquist <git@chary.us>
1 parent 4815a56 commit 6934c03

File tree

10 files changed

+294
-26
lines changed

10 files changed

+294
-26
lines changed

packages/config/__snapshots__/index_spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ exports['src/index .getDefaultValues returns list of public config keys 1'] = {
2323
"e2e": {},
2424
"env": {},
2525
"execTimeout": 60000,
26-
"exit": true,
2726
"experimentalFetchPolyfill": false,
2827
"experimentalInteractiveRunEvents": false,
2928
"experimentalSessionSupport": false,
@@ -100,7 +99,6 @@ exports['src/index .getPublicConfigKeys returns list of public config keys 1'] =
10099
"e2e",
101100
"env",
102101
"execTimeout",
103-
"exit",
104102
"experimentalFetchPolyfill",
105103
"experimentalInteractiveRunEvents",
106104
"experimentalSessionSupport",

packages/config/lib/options.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ const resolvedOptions: Array<ResolvedConfigOption> = [
140140
defaultValue: 60000,
141141
validation: validate.isNumber,
142142
canUpdateDuringTestTime: true,
143-
}, {
144-
name: 'exit',
145-
defaultValue: true,
146-
validation: validate.isBoolean,
147-
canUpdateDuringTestTime: false,
148143
}, {
149144
name: 'experimentalFetchPolyfill',
150145
defaultValue: false,

packages/server/lib/modes/run.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ module.exports = {
14591459
compressedVideoName: videoRecordProps.compressedVideoName,
14601460
endVideoCapture: videoRecordProps.endVideoCapture,
14611461
startedVideoCapture: videoRecordProps.startedVideoCapture,
1462-
exit: config.exit,
1462+
exit: options.exit,
14631463
videoCompression: options.videoCompression,
14641464
videoUploadOnPasses: options.videoUploadOnPasses,
14651465
quiet: options.quiet,
@@ -1618,6 +1618,7 @@ module.exports = {
16181618
quiet: options.quiet,
16191619
outputPath: options.outputPath,
16201620
testingType: options.testingType,
1621+
exit: options.exit,
16211622
})
16221623
.tap((runSpecs) => {
16231624
if (!options.quiet) {

packages/server/test/unit/config_spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,6 @@ describe('lib/config', () => {
14821482
e2e: { from: 'default', value: {} },
14831483
env: {},
14841484
execTimeout: { value: 60000, from: 'default' },
1485-
exit: { value: true, from: 'default' },
14861485
experimentalFetchPolyfill: { value: false, from: 'default' },
14871486
experimentalInteractiveRunEvents: { value: false, from: 'default' },
14881487
experimentalSourceRewriting: { value: false, from: 'default' },
@@ -1572,7 +1571,6 @@ describe('lib/config', () => {
15721571
downloadsFolder: { value: 'cypress/downloads', from: 'default' },
15731572
e2e: { from: 'default', value: {} },
15741573
execTimeout: { value: 60000, from: 'default' },
1575-
exit: { value: true, from: 'default' },
15761574
experimentalFetchPolyfill: { value: false, from: 'default' },
15771575
experimentalInteractiveRunEvents: { value: false, from: 'default' },
15781576
experimentalSourceRewriting: { value: false, from: 'default' },

packages/server/test/unit/modes/run_spec.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -810,21 +810,6 @@ describe('lib/modes/run', () => {
810810
})
811811
})
812812

813-
it('passes exit from config to waitForTestsToFinishRunning', function () {
814-
this.projectInstance.getConfig.restore()
815-
sinon.stub(this.projectInstance, 'getConfig').resolves({
816-
proxyUrl: 'http://localhost:12345',
817-
exit: false,
818-
})
819-
820-
return runMode.run()
821-
.then(() => {
822-
expect(runMode.waitForTestsToFinishRunning).to.be.calledWithMatch({
823-
exit: false,
824-
})
825-
})
826-
})
827-
828813
it('passes headed to openProject.launch', () => {
829814
const browser = { name: 'electron', family: 'chromium' }
830815

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
exports['cy.pause() in run mode / pauses with --headed and --no-exit'] = `
2+
3+
====================================================================================================
4+
5+
(Run Starting)
6+
7+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
8+
│ Cypress: 1.2.3 │
9+
│ Browser: FooBrowser 88 │
10+
│ Specs: 1 found (pause_spec.js) │
11+
│ Searched: cypress/integration/pause_spec.js │
12+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
13+
14+
15+
────────────────────────────────────────────────────────────────────────────────────────────────────
16+
17+
Running: pause_spec.js (1 of 1)
18+
19+
20+
cy.pause()
21+
✓ pauses
22+
23+
24+
1 passing
25+
26+
not exiting due to options.exit being false
27+
28+
`
29+
30+
exports['cy.pause() in run mode / does not pause if headless'] = `
31+
32+
====================================================================================================
33+
34+
(Run Starting)
35+
36+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
37+
│ Cypress: 1.2.3 │
38+
│ Browser: FooBrowser 88 │
39+
│ Specs: 1 found (pause_spec.js) │
40+
│ Searched: cypress/integration/pause_spec.js │
41+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
42+
43+
44+
────────────────────────────────────────────────────────────────────────────────────────────────────
45+
46+
Running: pause_spec.js (1 of 1)
47+
48+
49+
cy.pause()
50+
✓ pauses
51+
52+
53+
1 passing
54+
55+
not exiting due to options.exit being false
56+
57+
`
58+
59+
exports['cy.pause() in run mode / does not pause without --no-exit'] = `
60+
61+
====================================================================================================
62+
63+
(Run Starting)
64+
65+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
66+
│ Cypress: 1.2.3 │
67+
│ Browser: FooBrowser 88 │
68+
│ Specs: 1 found (pause_spec.js) │
69+
│ Searched: cypress/integration/pause_spec.js │
70+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
71+
72+
73+
────────────────────────────────────────────────────────────────────────────────────────────────────
74+
75+
Running: pause_spec.js (1 of 1)
76+
77+
78+
cy.pause()
79+
✓ pauses
80+
81+
82+
1 passing
83+
84+
85+
(Results)
86+
87+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
88+
│ Tests: 1 │
89+
│ Passing: 1 │
90+
│ Failing: 0 │
91+
│ Pending: 0 │
92+
│ Skipped: 0 │
93+
│ Screenshots: 0 │
94+
│ Video: true │
95+
│ Duration: X seconds │
96+
│ Spec Ran: pause_spec.js │
97+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
98+
99+
100+
(Video)
101+
102+
- Started processing: Compressing to 32 CRF
103+
- Finished processing: /XXX/XXX/XXX/cypress/videos/pause_spec.js.mp4 (X second)
104+
105+
106+
====================================================================================================
107+
108+
(Run Finished)
109+
110+
111+
Spec Tests Passing Failing Pending Skipped
112+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
113+
│ ✔ pause_spec.js XX:XX 1 1 - - - │
114+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
115+
✔ All specs passed! XX:XX 1 1 - - -
116+
117+
118+
`
119+
120+
exports['cy.pause() in run mode / does not pause without --headed and --no-exit'] = `
121+
122+
====================================================================================================
123+
124+
(Run Starting)
125+
126+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
127+
│ Cypress: 1.2.3 │
128+
│ Browser: FooBrowser 88 │
129+
│ Specs: 1 found (pause_spec.js) │
130+
│ Searched: cypress/integration/pause_spec.js │
131+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
132+
133+
134+
────────────────────────────────────────────────────────────────────────────────────────────────────
135+
136+
Running: pause_spec.js (1 of 1)
137+
138+
139+
cy.pause()
140+
✓ pauses
141+
142+
143+
1 passing
144+
145+
146+
(Results)
147+
148+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
149+
│ Tests: 1 │
150+
│ Passing: 1 │
151+
│ Failing: 0 │
152+
│ Pending: 0 │
153+
│ Skipped: 0 │
154+
│ Screenshots: 0 │
155+
│ Video: true │
156+
│ Duration: X seconds │
157+
│ Spec Ran: pause_spec.js │
158+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
159+
160+
161+
(Video)
162+
163+
- Started processing: Compressing to 32 CRF
164+
- Finished processing: /XXX/XXX/XXX/cypress/videos/pause_spec.js.mp4 (X second)
165+
166+
167+
====================================================================================================
168+
169+
(Run Finished)
170+
171+
172+
Spec Tests Passing Failing Pending Skipped
173+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
174+
│ ✔ pause_spec.js XX:XX 1 1 - - - │
175+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
176+
✔ All specs passed! XX:XX 1 1 - - -
177+
178+
179+
`

system-tests/lib/docker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ class DockerProcess extends EventEmitter implements SpawnerResult {
104104
},
105105
)
106106
}
107+
108+
kill (): boolean {
109+
throw new Error('.kill not implemented for DockerProcess.')
110+
}
107111
}
108112

109113
const checkBuiltBinary = async () => {

system-tests/lib/system-tests.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const snapshot = require('snap-shot-it')
22

3-
import type { SpawnOptions } from 'child_process'
3+
import type { SpawnOptions, ChildProcess } from 'child_process'
44
import stream from 'stream'
55
import { expect } from './spec_helper'
66
import { dockerSpawner } from './docker'
@@ -135,6 +135,10 @@ type ExecOptions = {
135135
* Pass a function to assert on and/or modify the stdout before snapshotting.
136136
*/
137137
onStdout?: (stdout: string) => string | void
138+
/**
139+
* Pass a function to receive the spawned process as an argument.
140+
*/
141+
onSpawn?: (sp: SpawnerResult) => void
138142
/**
139143
* User-supplied snapshot title. If unset, one will be autogenerated from the suite name.
140144
*/
@@ -265,6 +269,7 @@ export type SpawnerResult = {
265269
stderr: stream.Readable
266270
on(event: 'error', cb: (err: Error) => void): void
267271
on(event: 'exit', cb: (exitCode: number) => void): void
272+
kill: ChildProcess['kill']
268273
}
269274

270275
const cpSpawner: Spawner = (cmd, args, env, options) => {
@@ -1055,6 +1060,8 @@ const systemTests = {
10551060
const spawnerFn: Spawner = options.dockerImage ? dockerSpawner : cpSpawner
10561061
const sp: SpawnerResult = await spawnerFn(cmd, args, env, options)
10571062

1063+
options.onSpawn && options.onSpawn(sp)
1064+
10581065
const ColorOutput = function () {
10591066
const colorOutput = new stream.Transform()
10601067

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
describe('cy.pause()', () => {
2+
it('pauses', () => {
3+
let didPause = false
4+
5+
cy.visit('https://example.cypress.io')
6+
7+
cy.once('paused', (name) => {
8+
cy.once('paused', (name) => {
9+
didPause = true
10+
11+
// resume the rest of the commands so this
12+
// test ends
13+
Cypress.emit('resume:all')
14+
})
15+
16+
Cypress.emit('resume:next')
17+
})
18+
19+
cy.pause().wrap({}).should('deep.eq', {}).then(function () {
20+
if (Cypress.env('SHOULD_PAUSE')) {
21+
expect(didPause).to.be.true
22+
23+
// should no longer have onPaused
24+
expect(cy.state('onPaused')).to.be.null
25+
} else {
26+
expect(didPause).to.be.false
27+
}
28+
})
29+
})
30+
})

0 commit comments

Comments
 (0)