cypress-cli-select 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/cypress.config.js +0 -3
- package/index.js +105 -43
- package/package.json +1 -1
- package/tests/cli-component.spec.js +76 -0
- package/tests/cli-e2e.spec.js +69 -0
package/README.md
CHANGED
|
@@ -71,6 +71,35 @@ For selecting component specs:
|
|
|
71
71
|
npx cypress-cli-select run --component
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
If you want to skip straight to selecting specs, titles or tags:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx cypress-cli-select run --specs
|
|
78
|
+
# skips straight to spec selection
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npx cypress-cli-select run --titles
|
|
83
|
+
# skips to test title selection
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx cypress-cli-select run --tags
|
|
88
|
+
# skips to tag selection
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx cypress-cli-select run --specs --tags
|
|
93
|
+
# skips to spec selection, followed by tag selection
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx cypress-cli-select run --specs --titles
|
|
98
|
+
# skips to spec selection, followed by title selection
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Note**: You cannot pass both the `--titles` and `--tags` arguments.
|
|
102
|
+
|
|
74
103
|
You can also include more cli arguments similar to `cypress run`, as the command harnesses the power of [Cypress module API](https://docs.cypress.io/guides/guides/module-api):
|
|
75
104
|
|
|
76
105
|
```bash
|
package/cypress.config.js
CHANGED
package/index.js
CHANGED
|
@@ -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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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: "
|
|
212
|
-
value: "
|
|
238
|
+
name: "Specs",
|
|
239
|
+
value: "Specs",
|
|
213
240
|
},
|
|
214
241
|
{
|
|
215
|
-
name: "Test tags",
|
|
216
|
-
value: "
|
|
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
|
-
|
|
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 (
|
|
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.
|
|
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.
|
|
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 (
|
|
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.
|
|
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.
|
|
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");
|
package/package.json
CHANGED
|
@@ -120,6 +120,82 @@ describe("component: basic input prompt flows", () => {
|
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
+
describe("component: prompt flags skip beginning prompts", () => {
|
|
124
|
+
it("handles --specs flag", async () => {
|
|
125
|
+
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
|
126
|
+
resolve(__dirname, "../index.js"),
|
|
127
|
+
["--submit-focused"],
|
|
128
|
+
["--component"],
|
|
129
|
+
["--specs"],
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
expect(await findByText("Select specs to run")).toBeInTheConsole();
|
|
133
|
+
expect(await findByText("src/components/Clock.cy.js")).toBeInTheConsole();
|
|
134
|
+
expect(await findByText("src/components/Stepper.cy.js")).toBeInTheConsole();
|
|
135
|
+
|
|
136
|
+
userEvent.keyboard("[Enter]");
|
|
137
|
+
expect(
|
|
138
|
+
await findByText("Select specs to run: src/components/Clock.cy.js"),
|
|
139
|
+
).toBeInTheConsole();
|
|
140
|
+
expect(await findByText("Running Cypress")).toBeInTheConsole();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("handles --titles flag", async () => {
|
|
144
|
+
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
|
145
|
+
resolve(__dirname, "../index.js"),
|
|
146
|
+
["--submit-focused"],
|
|
147
|
+
["--component"],
|
|
148
|
+
["--titles"],
|
|
149
|
+
]);
|
|
150
|
+
|
|
151
|
+
expect(await findByText("Select tests to run")).toBeInTheConsole();
|
|
152
|
+
expect(
|
|
153
|
+
await findByText("Clock.cy.js > <Clock> > mounts"),
|
|
154
|
+
).toBeInTheConsole();
|
|
155
|
+
expect(
|
|
156
|
+
await findByText("Stepper.cy.js > <Stepper> > mounts"),
|
|
157
|
+
).toBeInTheConsole();
|
|
158
|
+
|
|
159
|
+
userEvent.keyboard("[Enter]");
|
|
160
|
+
expect(
|
|
161
|
+
await findByText("Select tests to run: Clock.cy.js > <Clock> > mounts"),
|
|
162
|
+
);
|
|
163
|
+
expect(await findByText("Running Cypress")).toBeInTheConsole();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("handles --tags flag", async () => {
|
|
167
|
+
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
|
168
|
+
resolve(__dirname, "../index.js"),
|
|
169
|
+
["--submit-focused"],
|
|
170
|
+
["--component"],
|
|
171
|
+
["--tags"],
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
expect(await findByText("Select tags to run")).toBeInTheConsole();
|
|
175
|
+
expect(await findByText("@p3")).toBeInTheConsole();
|
|
176
|
+
|
|
177
|
+
userEvent.keyboard("[ArrowDown]");
|
|
178
|
+
userEvent.keyboard("[Enter]");
|
|
179
|
+
|
|
180
|
+
expect(await findByText("Select tags to run: @p3"));
|
|
181
|
+
expect(await findByText("Running Cypress")).toBeInTheConsole();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("cannot pass both --titles and --tags", async () => {
|
|
185
|
+
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
|
186
|
+
resolve(__dirname, "../index.js"),
|
|
187
|
+
["--submit-focused"],
|
|
188
|
+
["--component"],
|
|
189
|
+
["--titles"],
|
|
190
|
+
["--tags"],
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
expect(
|
|
194
|
+
await findByText("Cannot choose both titles and tags"),
|
|
195
|
+
).toBeInTheConsole();
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
123
199
|
describe("component: print selected displays prior to run", () => {
|
|
124
200
|
it("handles spec display", async () => {
|
|
125
201
|
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
package/tests/cli-e2e.spec.js
CHANGED
|
@@ -114,6 +114,75 @@ describe("e2e: basic input prompt flows", () => {
|
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
+
describe("e2e: prompt flags skip beginning prompts", () => {
|
|
118
|
+
it("handles --specs flag", async () => {
|
|
119
|
+
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
|
120
|
+
resolve(__dirname, "../index.js"),
|
|
121
|
+
["--submit-focused"],
|
|
122
|
+
["--specs"],
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
expect(await findByText("Select specs to run")).toBeInTheConsole();
|
|
126
|
+
expect(
|
|
127
|
+
await findByText("cypress/e2e/1-getting-started/todo.cy.js"),
|
|
128
|
+
).toBeInTheConsole();
|
|
129
|
+
expect(
|
|
130
|
+
await findByText("cypress/e2e/2-advanced-examples/actions.cy.js"),
|
|
131
|
+
).toBeInTheConsole();
|
|
132
|
+
expect(
|
|
133
|
+
await findByText("cypress/e2e/2-advanced-examples/aliasing.cy.js"),
|
|
134
|
+
).toBeInTheConsole();
|
|
135
|
+
|
|
136
|
+
userEvent.keyboard("[Enter]");
|
|
137
|
+
expect(await findByText("Running Cypress")).toBeInTheConsole();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("handles --titles flag", async () => {
|
|
141
|
+
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
|
142
|
+
resolve(__dirname, "../index.js"),
|
|
143
|
+
["--submit-focused"],
|
|
144
|
+
["--titles"],
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
expect(await findByText("Select tests to run")).toBeInTheConsole();
|
|
148
|
+
expect(
|
|
149
|
+
await findByText(
|
|
150
|
+
"todo.cy.js > example to-do app > displays two todo items by default",
|
|
151
|
+
),
|
|
152
|
+
).toBeInTheConsole();
|
|
153
|
+
|
|
154
|
+
userEvent.keyboard("[Enter]");
|
|
155
|
+
expect(await findByText("Running Cypress")).toBeInTheConsole();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("handles --tags flag", async () => {
|
|
159
|
+
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
|
160
|
+
resolve(__dirname, "../index.js"),
|
|
161
|
+
["--submit-focused"],
|
|
162
|
+
["--tags"],
|
|
163
|
+
]);
|
|
164
|
+
|
|
165
|
+
expect(await findByText("Select tags to run")).toBeInTheConsole();
|
|
166
|
+
expect(await findByText("@smoke")).toBeInTheConsole();
|
|
167
|
+
|
|
168
|
+
userEvent.keyboard("[Enter]");
|
|
169
|
+
expect(await findByText("Running Cypress")).toBeInTheConsole();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("cannot pass both --titles and --tags", async () => {
|
|
173
|
+
const { findByText, userEvent } = await render("cd ../../../ && node", [
|
|
174
|
+
resolve(__dirname, "../index.js"),
|
|
175
|
+
["--submit-focused"],
|
|
176
|
+
["--titles"],
|
|
177
|
+
["--tags"],
|
|
178
|
+
]);
|
|
179
|
+
|
|
180
|
+
expect(
|
|
181
|
+
await findByText("Cannot choose both titles and tags"),
|
|
182
|
+
).toBeInTheConsole();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
117
186
|
describe("e2e: print selected displays prior to run", () => {
|
|
118
187
|
it("handles spec display", async () => {
|
|
119
188
|
const { findByText, userEvent } = await render("cd ../../../ && node", [
|