1
- import Debug from " debug" ;
1
+ import Debug from ' debug' ;
2
2
3
- import { P , match } from " ts-pattern" ;
4
- import { DetectedBrowser , ValidatedCurrentsParameters } from " ../../types" ;
5
- import { bootCypress } from " ../bootstrap" ;
6
- import { info , warn } from " ../log" ;
7
- import { getConfigFilePath } from " ./path" ;
3
+ import { P , match } from ' ts-pattern' ;
4
+ import { DetectedBrowser , ValidatedCurrentsParameters } from ' ../../types' ;
5
+ import { bootCypress } from ' ../bootstrap' ;
6
+ import { info , warn } from ' ../log' ;
7
+ import { getConfigFilePath } from ' ./path' ;
8
8
9
- const debug = Debug ( " currents:config" ) ;
9
+ const debug = Debug ( ' currents:config' ) ;
10
10
11
11
export type E2EConfig = {
12
12
batchSize : number ;
@@ -18,6 +18,14 @@ export type ComponentConfig = {
18
18
type RetryConfig = {
19
19
hardFailureMaxRetries : number ;
20
20
} ;
21
+
22
+ /**
23
+ * This is the type for `currents.config.*s`. If you are not officially using TypeScript,
24
+ * you can still type the exported config in your IDE by adding the following as a block comment
25
+ * above `module.exports` / `export default`:
26
+ *
27
+ * `@type {import('cypress-cloud').CurrentsConfig}`
28
+ */
21
29
export type CurrentsConfig = {
22
30
projectId ?: string ;
23
31
recordKey ?: string ;
@@ -37,7 +45,7 @@ const defaultConfig: CurrentsConfig = {
37
45
component : {
38
46
batchSize : 5 ,
39
47
} ,
40
- cloudServiceUrl : " https://cy.currents.dev" ,
48
+ cloudServiceUrl : ' https://cy.currents.dev' ,
41
49
networkHeaders : undefined ,
42
50
} ;
43
51
@@ -68,10 +76,7 @@ export async function getCurrentsConfig(
68
76
}
69
77
}
70
78
71
- warn (
72
- "Failed to load config file, falling back to the default config. Attempted locations: %s" ,
73
- configFilePath
74
- ) ;
79
+ warn ( 'Failed to load config file, falling back to the default config. Attempted locations: %s' , configFilePath ) ;
75
80
_config = defaultConfig ;
76
81
return _config ;
77
82
}
@@ -81,14 +86,14 @@ async function loadConfigFile(filepath: string) {
81
86
debug ( "loading currents config file from '%s'" , filepath ) ;
82
87
return await import ( filepath ) ;
83
88
} catch ( e ) {
84
- debug ( " failed loading config file from: %s" , e ) ;
89
+ debug ( ' failed loading config file from: %s' , e ) ;
85
90
return null ;
86
91
}
87
92
}
88
93
89
94
export type MergedConfig = Awaited < ReturnType < typeof getMergedConfig > > ;
90
95
export async function getMergedConfig ( params : ValidatedCurrentsParameters ) {
91
- debug ( " resolving cypress config" ) ;
96
+ debug ( ' resolving cypress config' ) ;
92
97
const cypressResolvedConfig :
93
98
| ( Cypress . ResolvedConfigOptions & {
94
99
projectRoot : string ;
@@ -97,12 +102,12 @@ export async function getMergedConfig(params: ValidatedCurrentsParameters) {
97
102
} )
98
103
| undefined = await bootCypress ( params ) ;
99
104
100
- debug ( " cypress resolvedConfig: %O" , cypressResolvedConfig ) ;
105
+ debug ( ' cypress resolvedConfig: %O' , cypressResolvedConfig ) ;
101
106
102
107
// @ts -ignore
103
108
const rawE2EPattern = cypressResolvedConfig . rawJson ?. e2e ?. specPattern ;
104
109
let additionalIgnorePattern : string [ ] = [ ] ;
105
- if ( params . testingType === " component" && rawE2EPattern ) {
110
+ if ( params . testingType === ' component' && rawE2EPattern ) {
106
111
// @ts -ignore
107
112
additionalIgnorePattern = rawE2EPattern ;
108
113
}
@@ -112,14 +117,14 @@ export async function getMergedConfig(params: ValidatedCurrentsParameters) {
112
117
const result = {
113
118
projectRoot : cypressResolvedConfig ?. projectRoot || process . cwd ( ) ,
114
119
projectId : params . projectId ,
115
- specPattern : cypressResolvedConfig ?. specPattern || " **/*.*" ,
120
+ specPattern : cypressResolvedConfig ?. specPattern || ' **/*.*' ,
116
121
excludeSpecPattern :
117
122
// @ts -ignore
118
123
cypressResolvedConfig ?. resolved . excludeSpecPattern . value ?? [ ] ,
119
124
additionalIgnorePattern,
120
125
resolved : cypressResolvedConfig ,
121
126
experimentalCoverageRecording : params . experimentalCoverageRecording ,
122
127
} ;
123
- debug ( " merged config: %O" , result ) ;
128
+ debug ( ' merged config: %O' , result ) ;
124
129
return result ;
125
130
}
0 commit comments