@@ -115,6 +115,29 @@ async function runSelectedSpecs() {
115
115
process . env . SUBMIT_FOCUSED = true ;
116
116
}
117
117
118
+ if ( process . argv . includes ( "--titles" ) && process . argv . includes ( "--tags" ) ) {
119
+ console . log ( "\n" ) ;
120
+ console . log ( pc . redBright ( pc . bold ( ` Cannot choose both titles and tags ` ) ) ) ;
121
+ process . exit ( ) ;
122
+ }
123
+
124
+ if ( process . argv . includes ( "--titles" ) ) {
125
+ findAndRemoveArgv ( "--titles" ) ;
126
+ process . env . TEST_TITLES = true ;
127
+ process . env . CY_GREP_FILTER_METHOD = "Titles" ;
128
+ }
129
+
130
+ if ( process . argv . includes ( "--specs" ) ) {
131
+ findAndRemoveArgv ( "--specs" ) ;
132
+ process . env . TEST_SPECS = true ;
133
+ }
134
+
135
+ if ( process . argv . includes ( "--tags" ) ) {
136
+ findAndRemoveArgv ( "--tags" ) ;
137
+ process . env . TEST_TAGS = true ;
138
+ process . env . CY_GREP_FILTER_METHOD = "Tags" ;
139
+ }
140
+
118
141
// set the testing type
119
142
// this is used by find-cypress-specs package to get the appropriate spec list
120
143
if ( process . argv . includes ( "--component" ) ) {
@@ -125,6 +148,30 @@ async function runSelectedSpecs() {
125
148
126
149
try {
127
150
// help menu options
151
+ yarg
152
+ . completion ( "--specs" , false )
153
+ . option ( "specs" , {
154
+ desc : "Skips to spec selection prompt" ,
155
+ type : "boolean" ,
156
+ } )
157
+ . example ( "npx cypress-cli-select run --specs" ) ;
158
+
159
+ yarg
160
+ . completion ( "--titles" , false )
161
+ . option ( "titles" , {
162
+ desc : "Skips to test title selection prompt" ,
163
+ type : "boolean" ,
164
+ } )
165
+ . example ( "npx cypress-cli-select run --titles" ) ;
166
+
167
+ yarg
168
+ . completion ( "--tags" , false )
169
+ . option ( "tags" , {
170
+ desc : "Skips to tag selection prompt" ,
171
+ type : "boolean" ,
172
+ } )
173
+ . example ( "npx cypress-cli-select run --tags" ) ;
174
+
128
175
yarg
129
176
. completion ( "--print-selected" , false )
130
177
. option ( "print-selected" , {
@@ -174,51 +221,66 @@ async function runSelectedSpecs() {
174
221
* Test titles/tags requires the cy-grep package
175
222
*/
176
223
// 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 ,
224
+ if (
225
+ ! process . env . TEST_TITLES &&
226
+ ! process . env . TEST_SPECS &&
227
+ ! process . env . TEST_TAGS
228
+ ) {
229
+ const specAndTestPrompt = await select ( {
230
+ message : "Choose to filter by specs, specific test titles or tags: " ,
231
+ multiple : disableTitleTagChoice ? false : true ,
232
+ defaultValue : disableTitleTagChoice ? "Specs" : null ,
233
+ clearInputWhenSelected : true ,
234
+ selectFocusedOnSubmit : process . env . SUBMIT_FOCUSED ,
235
+ canToggleAll : true ,
209
236
options : [
210
237
{
211
- name : "Test titles " ,
212
- value : "Titles " ,
238
+ name : "Specs " ,
239
+ value : "Specs " ,
213
240
} ,
214
241
{
215
- name : "Test tags" ,
216
- value : "Tags" ,
242
+ name : "Test titles or tags (requires cy-grep)" ,
243
+ value : "Tests or tags" ,
244
+ disabled : disableTitleTagChoice ,
217
245
} ,
218
246
] ,
219
247
required : true ,
220
248
} ) ;
221
- process . env . CY_GREP_FILTER_METHOD = titleOrTagPrompt ;
249
+ if ( specAndTestPrompt . includes ( "Specs" ) ) {
250
+ process . env . TEST_SPECS = true ;
251
+ }
252
+
253
+ /*
254
+
255
+ /*
256
+ * NOTE:: Choose test titles or tags
257
+ * This requires the cy-grep package
258
+ */
259
+ if ( specAndTestPrompt . includes ( "Tests or tags" ) ) {
260
+ // Prompt for use to select test titles or tags option
261
+ const titleOrTagPrompt = await select ( {
262
+ message : "Choose to filter by specific test titles or tags: " ,
263
+ multiple : false ,
264
+ options : [
265
+ {
266
+ name : "Test titles" ,
267
+ value : "Titles" ,
268
+ } ,
269
+ {
270
+ name : "Test tags" ,
271
+ value : "Tags" ,
272
+ } ,
273
+ ] ,
274
+ required : true ,
275
+ } ) ;
276
+ process . env . CY_GREP_FILTER_METHOD = titleOrTagPrompt ;
277
+ if ( titleOrTagPrompt . includes ( "Titles" ) ) {
278
+ process . env . TEST_TITLES = true ;
279
+ }
280
+ if ( titleOrTagPrompt . includes ( "Tags" ) ) {
281
+ process . env . TEST_TAGS = true ;
282
+ }
283
+ }
222
284
}
223
285
// Arrays for storing specs and/or tests
224
286
// If user passes --print-selected
@@ -228,7 +290,7 @@ async function runSelectedSpecs() {
228
290
/*
229
291
* NOTE:: Spec section
230
292
*/
231
- if ( specAndTestPrompt . includes ( "Specs" ) ) {
293
+ if ( process . env . TEST_SPECS ) {
232
294
const specs = getSpecs ( undefined , process . env . TESTING_TYPE , false ) ;
233
295
234
296
if ( specs . length > 0 ) {
@@ -334,7 +396,7 @@ async function runSelectedSpecs() {
334
396
/*
335
397
* NOTE:: Test Title section
336
398
*/
337
- if ( process . env . CY_GREP_FILTER_METHOD === "Titles" ) {
399
+ if ( process . env . TEST_TITLES ) {
338
400
const specs = getSpecs ( undefined , process . env . TESTING_TYPE , false ) ;
339
401
340
402
if ( specs . length > 0 ) {
@@ -463,7 +525,7 @@ async function runSelectedSpecs() {
463
525
/*
464
526
* NOTE:: Tags section
465
527
*/
466
- if ( process . env . CY_GREP_FILTER_METHOD === "Tags" ) {
528
+ if ( process . env . TEST_TAGS ) {
467
529
const specs = getSpecs ( undefined , process . env . TESTING_TYPE , false ) ;
468
530
469
531
if ( specs . length > 0 ) {
@@ -532,19 +594,19 @@ async function runSelectedSpecs() {
532
594
// NOTE : --print-selected used to show all selected specs/titles/tags
533
595
if ( process . argv . includes ( "--print-selected" ) ) {
534
596
findAndRemoveArgv ( "--print-selected" ) ;
535
- if ( specAndTestPrompt . includes ( "Specs" ) ) {
597
+ if ( process . env . TEST_SPECS ) {
536
598
console . log ( "\n" ) ;
537
599
console . log ( pc . bgGreen ( pc . black ( pc . bold ( ` Spec(s) selected: ` ) ) ) ) ;
538
600
console . log ( "\n" ) ;
539
601
console . log ( specArr ) ;
540
602
}
541
- if ( process . env . CY_GREP_FILTER_METHOD === "Titles" ) {
603
+ if ( process . env . TEST_TITLES ) {
542
604
console . log ( "\n" ) ;
543
605
console . log ( pc . bgGreen ( pc . black ( pc . bold ( ` Test(s) selected: ` ) ) ) ) ;
544
606
console . log ( "\n" ) ;
545
607
console . log ( testArr ) ;
546
608
}
547
- if ( process . env . CY_GREP_FILTER_METHOD === "Tags" ) {
609
+ if ( process . env . TEST_TAGS ) {
548
610
console . log ( "\n" ) ;
549
611
console . log ( pc . bgGreen ( pc . black ( pc . bold ( ` Tag(s) selected: ` ) ) ) ) ;
550
612
console . log ( "\n" ) ;
0 commit comments