@@ -115,6 +115,23 @@ async function runSelectedSpecs() {
115
115
process . env . SUBMIT_FOCUSED = true ;
116
116
}
117
117
118
+ if ( process . argv . includes ( "--titles" ) ) {
119
+ findAndRemoveArgv ( "--titles" ) ;
120
+ process . env . TEST_TITLES = true ;
121
+ process . env . CY_GREP_FILTER_METHOD = "Titles" ;
122
+ }
123
+
124
+ if ( process . argv . includes ( "--specs" ) ) {
125
+ findAndRemoveArgv ( "--specs" ) ;
126
+ process . env . TEST_SPECS = true ;
127
+ }
128
+
129
+ if ( process . argv . includes ( "--tags" ) ) {
130
+ findAndRemoveArgv ( "--tags" ) ;
131
+ process . env . TEST_TAGS = true ;
132
+ process . env . CY_GREP_FILTER_METHOD = "Tags" ;
133
+ }
134
+
118
135
// set the testing type
119
136
// this is used by find-cypress-specs package to get the appropriate spec list
120
137
if ( process . argv . includes ( "--component" ) ) {
@@ -125,6 +142,30 @@ async function runSelectedSpecs() {
125
142
126
143
try {
127
144
// help menu options
145
+ yarg
146
+ . completion ( "--specs" , false )
147
+ . option ( "specs" , {
148
+ desc : "Skips to spec selection prompt" ,
149
+ type : "boolean" ,
150
+ } )
151
+ . example ( "npx cypress-cli-select run --specs" ) ;
152
+
153
+ yarg
154
+ . completion ( "--titles" , false )
155
+ . option ( "titles" , {
156
+ desc : "Skips to test title selection prompt" ,
157
+ type : "boolean" ,
158
+ } )
159
+ . example ( "npx cypress-cli-select run --titles" ) ;
160
+
161
+ yarg
162
+ . completion ( "--tags" , false )
163
+ . option ( "tags" , {
164
+ desc : "Skips to tag selection prompt" ,
165
+ type : "boolean" ,
166
+ } )
167
+ . example ( "npx cypress-cli-select run --tags" ) ;
168
+
128
169
yarg
129
170
. completion ( "--print-selected" , false )
130
171
. option ( "print-selected" , {
@@ -174,51 +215,66 @@ async function runSelectedSpecs() {
174
215
* Test titles/tags requires the cy-grep package
175
216
*/
176
217
// Prompt for use to select spec and test titles or tags option
177
- const specAndTestPrompt = await select ( {
178
- message : "Choose to filter by specs, specific test titles or tags: " ,
179
- multiple : disableTitleTagChoice ? false : true ,
180
- defaultValue : disableTitleTagChoice ? "Specs" : null ,
181
- clearInputWhenSelected : true ,
182
- selectFocusedOnSubmit : process . env . SUBMIT_FOCUSED ,
183
- canToggleAll : true ,
184
- options : [
185
- {
186
- name : "Specs" ,
187
- value : "Specs" ,
188
- } ,
189
- {
190
- name : "Test titles or tags (requires cy-grep)" ,
191
- value : "Tests or tags" ,
192
- disabled : disableTitleTagChoice ,
193
- } ,
194
- ] ,
195
- required : true ,
196
- } ) ;
197
-
198
- /*
199
-
200
- /*
201
- * NOTE:: Choose test titles or tags
202
- * This requires the cy-grep package
203
- */
204
- if ( specAndTestPrompt . includes ( "Tests or tags" ) ) {
205
- // Prompt for use to select test titles or tags option
206
- const titleOrTagPrompt = await select ( {
207
- message : "Choose to filter by specific test titles or tags: " ,
208
- multiple : false ,
218
+ if (
219
+ ! process . env . TEST_TITLES &&
220
+ ! process . env . TEST_SPECS &&
221
+ ! process . env . TEST_TAGS
222
+ ) {
223
+ const specAndTestPrompt = await select ( {
224
+ message : "Choose to filter by specs, specific test titles or tags: " ,
225
+ multiple : disableTitleTagChoice ? false : true ,
226
+ defaultValue : disableTitleTagChoice ? "Specs" : null ,
227
+ clearInputWhenSelected : true ,
228
+ selectFocusedOnSubmit : process . env . SUBMIT_FOCUSED ,
229
+ canToggleAll : true ,
209
230
options : [
210
231
{
211
- name : "Test titles " ,
212
- value : "Titles " ,
232
+ name : "Specs " ,
233
+ value : "Specs " ,
213
234
} ,
214
235
{
215
- name : "Test tags" ,
216
- value : "Tags" ,
236
+ name : "Test titles or tags (requires cy-grep)" ,
237
+ value : "Tests or tags" ,
238
+ disabled : disableTitleTagChoice ,
217
239
} ,
218
240
] ,
219
241
required : true ,
220
242
} ) ;
221
- process . env . CY_GREP_FILTER_METHOD = titleOrTagPrompt ;
243
+ if ( specAndTestPrompt . includes ( "Specs" ) ) {
244
+ process . env . TEST_SPECS = true ;
245
+ }
246
+
247
+ /*
248
+
249
+ /*
250
+ * NOTE:: Choose test titles or tags
251
+ * This requires the cy-grep package
252
+ */
253
+ if ( specAndTestPrompt . includes ( "Tests or tags" ) ) {
254
+ // Prompt for use to select test titles or tags option
255
+ const titleOrTagPrompt = await select ( {
256
+ message : "Choose to filter by specific test titles or tags: " ,
257
+ multiple : false ,
258
+ options : [
259
+ {
260
+ name : "Test titles" ,
261
+ value : "Titles" ,
262
+ } ,
263
+ {
264
+ name : "Test tags" ,
265
+ value : "Tags" ,
266
+ } ,
267
+ ] ,
268
+ required : true ,
269
+ } ) ;
270
+ process . env . CY_GREP_FILTER_METHOD = titleOrTagPrompt ;
271
+ if ( titleOrTagPrompt . includes ( "Titles" ) ) {
272
+ process . env . TEST_TITLES = true ;
273
+ }
274
+ if ( titleOrTagPrompt . includes ( "Tags" ) ) {
275
+ process . env . TEST_TAGS = true ;
276
+ }
277
+ }
222
278
}
223
279
// Arrays for storing specs and/or tests
224
280
// If user passes --print-selected
@@ -228,7 +284,7 @@ async function runSelectedSpecs() {
228
284
/*
229
285
* NOTE:: Spec section
230
286
*/
231
- if ( specAndTestPrompt . includes ( "Specs" ) ) {
287
+ if ( process . env . TEST_SPECS ) {
232
288
const specs = getSpecs ( undefined , process . env . TESTING_TYPE , false ) ;
233
289
234
290
if ( specs . length > 0 ) {
@@ -334,7 +390,7 @@ async function runSelectedSpecs() {
334
390
/*
335
391
* NOTE:: Test Title section
336
392
*/
337
- if ( process . env . CY_GREP_FILTER_METHOD === "Titles" ) {
393
+ if ( process . env . TEST_TITLES ) {
338
394
const specs = getSpecs ( undefined , process . env . TESTING_TYPE , false ) ;
339
395
340
396
if ( specs . length > 0 ) {
@@ -463,7 +519,7 @@ async function runSelectedSpecs() {
463
519
/*
464
520
* NOTE:: Tags section
465
521
*/
466
- if ( process . env . CY_GREP_FILTER_METHOD === "Tags" ) {
522
+ if ( process . env . TEST_TAGS ) {
467
523
const specs = getSpecs ( undefined , process . env . TESTING_TYPE , false ) ;
468
524
469
525
if ( specs . length > 0 ) {
@@ -532,19 +588,19 @@ async function runSelectedSpecs() {
532
588
// NOTE : --print-selected used to show all selected specs/titles/tags
533
589
if ( process . argv . includes ( "--print-selected" ) ) {
534
590
findAndRemoveArgv ( "--print-selected" ) ;
535
- if ( specAndTestPrompt . includes ( "Specs" ) ) {
591
+ if ( process . env . TEST_SPECS ) {
536
592
console . log ( "\n" ) ;
537
593
console . log ( pc . bgGreen ( pc . black ( pc . bold ( ` Spec(s) selected: ` ) ) ) ) ;
538
594
console . log ( "\n" ) ;
539
595
console . log ( specArr ) ;
540
596
}
541
- if ( process . env . CY_GREP_FILTER_METHOD === "Titles" ) {
597
+ if ( process . env . TEST_TITLES ) {
542
598
console . log ( "\n" ) ;
543
599
console . log ( pc . bgGreen ( pc . black ( pc . bold ( ` Test(s) selected: ` ) ) ) ) ;
544
600
console . log ( "\n" ) ;
545
601
console . log ( testArr ) ;
546
602
}
547
- if ( process . env . CY_GREP_FILTER_METHOD === "Tags" ) {
603
+ if ( process . env . TEST_TAGS ) {
548
604
console . log ( "\n" ) ;
549
605
console . log ( pc . bgGreen ( pc . black ( pc . bold ( ` Tag(s) selected: ` ) ) ) ) ;
550
606
console . log ( "\n" ) ;
0 commit comments