@@ -9,16 +9,17 @@ require('./environment')
9
9
// essentially do it all again when we boot the correct
10
10
// mode.
11
11
12
- const Promise = require ( 'bluebird' )
13
- const debug = require ( 'debug' ) ( 'cypress:server:cypress' )
14
- const { getPublicConfigKeys } = require ( '@packages/config' )
15
- const argsUtils = require ( './util/args' )
16
- const { telemetry } = require ( '@packages/telemetry' )
17
- const { getCtx, hasCtx } = require ( '@packages/data-context' )
18
-
19
- const warning = ( code , args ) => {
20
- return require ( './errors' ) . warning ( code , args )
21
- }
12
+ import Promise from 'bluebird'
13
+ import Debug from 'debug'
14
+ import { getPublicConfigKeys } from '@packages/config'
15
+ import argsUtils from './util/args'
16
+ import { telemetry } from '@packages/telemetry'
17
+ import { getCtx , hasCtx } from '@packages/data-context'
18
+ import { warning as errorsWarning } from './errors'
19
+
20
+ const debug = Debug ( 'cypress:server:cypress' )
21
+
22
+ type Mode = 'exit' | 'info' | 'interactive' | 'pkg' | 'record' | 'results' | 'run' | 'smokeTest' | 'version' | 'returnPkg' | 'exitWithCode'
22
23
23
24
const exit = async ( code = 0 ) => {
24
25
// TODO: we shouldn't have to do this
@@ -27,7 +28,7 @@ const exit = async (code = 0) => {
27
28
debug ( 'about to exit with code' , code )
28
29
29
30
if ( hasCtx ( ) ) {
30
- await getCtx ( ) . lifecycleManager . mainProcessWillDisconnect ( ) . catch ( ( err ) => {
31
+ await getCtx ( ) . lifecycleManager . mainProcessWillDisconnect ( ) . catch ( ( err : any ) => {
31
32
debug ( 'mainProcessWillDisconnect errored with: ' , err )
32
33
} )
33
34
}
@@ -37,14 +38,14 @@ const exit = async (code = 0) => {
37
38
span ?. setAttribute ( 'exitCode' , code )
38
39
span ?. end ( )
39
40
40
- await telemetry . shutdown ( ) . catch ( ( err ) => {
41
+ await telemetry . shutdown ( ) . catch ( ( err : any ) => {
41
42
debug ( 'telemetry shutdown errored with: ' , err )
42
43
} )
43
44
44
45
return process . exit ( code )
45
46
}
46
47
47
- const showWarningForInvalidConfig = ( options ) => {
48
+ const showWarningForInvalidConfig = ( options : any ) => {
48
49
const publicConfigKeys = getPublicConfigKeys ( )
49
50
const invalidConfigOptions = require ( 'lodash' ) . keys ( options . config ) . reduce ( ( invalid , option ) => {
50
51
if ( ! publicConfigKeys . find ( ( configKey ) => configKey === option ) ) {
@@ -55,15 +56,17 @@ const showWarningForInvalidConfig = (options) => {
55
56
} , [ ] )
56
57
57
58
if ( invalidConfigOptions . length && options . invokedFromCli ) {
58
- return warning ( 'INVALID_CONFIG_OPTION' , invalidConfigOptions )
59
+ return errorsWarning ( 'INVALID_CONFIG_OPTION' , invalidConfigOptions )
59
60
}
61
+
62
+ return undefined
60
63
}
61
64
62
65
const exit0 = ( ) => {
63
66
return exit ( 0 )
64
67
}
65
68
66
- const exitErr = ( err ) => {
69
+ const exitErr = ( err : any ) => {
67
70
// log errors to the console
68
71
// and potentially raygun
69
72
// and exit with 1
@@ -77,12 +80,12 @@ const exitErr = (err) => {
77
80
} )
78
81
}
79
82
80
- module . exports = {
83
+ export = {
81
84
isCurrentlyRunningElectron ( ) {
82
85
return require ( './util/electron-app' ) . isRunning ( )
83
86
} ,
84
87
85
- runElectron ( mode , options ) {
88
+ runElectron ( mode : Mode , options : any ) {
86
89
// wrap all of this in a promise to force the
87
90
// promise interface - even if it doesn't matter
88
91
// in dev mode due to cp.spawn
@@ -95,7 +98,7 @@ module.exports = {
95
98
// if we weren't invoked from the CLI
96
99
// then display a warning to the user
97
100
if ( ! options . invokedFromCli ) {
98
- warning ( 'INVOKED_BINARY_OUTSIDE_NPM_MODULE' )
101
+ errorsWarning ( 'INVOKED_BINARY_OUTSIDE_NPM_MODULE' )
99
102
}
100
103
101
104
debug ( 'running Electron currently' )
@@ -107,7 +110,7 @@ module.exports = {
107
110
debug ( 'starting Electron' )
108
111
const cypressElectron = require ( '@packages/electron' )
109
112
110
- const fn = ( code ) => {
113
+ const fn = ( code : number ) => {
111
114
// juggle up the totalFailed since our outer
112
115
// promise is expecting this object structure
113
116
debug ( 'electron finished with' , code )
@@ -131,7 +134,7 @@ module.exports = {
131
134
} )
132
135
} ,
133
136
134
- start ( argv = [ ] ) {
137
+ start ( argv : any = [ ] ) {
135
138
debug ( 'starting cypress with argv %o' , argv )
136
139
137
140
// if the CLI passed "--" somewhere, we need to remove it
@@ -144,7 +147,7 @@ module.exports = {
144
147
options = argsUtils . toObject ( argv )
145
148
146
149
showWarningForInvalidConfig ( options )
147
- } catch ( argumentsError ) {
150
+ } catch ( argumentsError : any ) {
148
151
debug ( 'could not parse CLI arguments: %o' , argv )
149
152
150
153
// note - this is promise-returned call
@@ -153,6 +156,7 @@ module.exports = {
153
156
154
157
debug ( 'from argv %o got options %o' , argv , options )
155
158
159
+ // @ts -expect-error TODO: Fix type that says attachRecordKey is not a function
156
160
telemetry . exporter ( ) ?. attachRecordKey ( options . key )
157
161
158
162
if ( options . headless ) {
@@ -202,14 +206,14 @@ module.exports = {
202
206
} )
203
207
} ,
204
208
205
- startInMode ( mode , options ) {
209
+ startInMode ( mode : Mode , options : any ) {
206
210
debug ( 'starting in mode %s with options %o' , mode , options )
207
211
208
212
switch ( mode ) {
209
213
case 'version' :
210
214
return require ( './modes/pkg' ) ( options )
211
215
. get ( 'version' )
212
- . then ( ( version ) => {
216
+ . then ( ( version : any ) => {
213
217
return console . log ( version ) // eslint-disable-line no-console
214
218
} ) . then ( exit0 )
215
219
. catch ( exitErr )
@@ -221,7 +225,7 @@ module.exports = {
221
225
222
226
case 'smokeTest' :
223
227
return this . runElectron ( mode , options )
224
- . then ( ( pong ) => {
228
+ . then ( ( pong : any ) => {
225
229
if ( ! this . isCurrentlyRunningElectron ( ) ) {
226
230
return pong
227
231
}
@@ -236,7 +240,7 @@ module.exports = {
236
240
237
241
case 'returnPkg' :
238
242
return require ( './modes/pkg' ) ( options )
239
- . then ( ( pkg ) => {
243
+ . then ( ( pkg : any ) => {
240
244
return console . log ( JSON . stringify ( pkg ) ) // eslint-disable-line no-console
241
245
} ) . then ( exit0 )
242
246
. catch ( exitErr )
@@ -250,7 +254,7 @@ module.exports = {
250
254
// run headlessly and exit
251
255
// with num of totalFailed
252
256
return this . runElectron ( mode , options )
253
- . then ( ( results ) => {
257
+ . then ( ( results : any ) => {
254
258
if ( results . runs ) {
255
259
const isCanceled = results . runs . filter ( ( run ) => run . skippedSpec ) . length
256
260
5 commit comments
cypress-bot[bot] commentedon Mar 6, 2025
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
cypress-bot[bot] commentedon Mar 6, 2025
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
cypress-bot[bot] commentedon Mar 6, 2025
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
cypress-bot[bot] commentedon Mar 6, 2025
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
cypress-bot[bot] commentedon Mar 6, 2025
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: