find-cypress-specs 1.31.0 → 1.31.1
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 +9 -0
- package/bin/find.js +55 -55
- package/package.json +1 -1
- package/src/index.js +5 -2
package/README.md
CHANGED
|
@@ -111,6 +111,15 @@ $ npx find-cypress-specs --branch main --tagged @user,@preview
|
|
|
111
111
|
# and that have any tests or suites inside tagged "@user" or "@preview"
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
### count tagged changed specs
|
|
115
|
+
|
|
116
|
+
Let's say we changed 2 specs that have tests tagged `@user`. We can output the count by adding `--count` option
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
$ npx find-cypress-specs --branch main --tagged @user --count
|
|
120
|
+
2
|
|
121
|
+
```
|
|
122
|
+
|
|
114
123
|
## Test names
|
|
115
124
|
|
|
116
125
|
You can print each spec file with the suite and test names inside of it (found using [find-test-names](https://github.com/bahmutov/find-test-names))
|
package/bin/find.js
CHANGED
|
@@ -61,61 +61,7 @@ const specType = args['--component'] ? 'component' : 'e2e'
|
|
|
61
61
|
|
|
62
62
|
const specs = getSpecs(undefined, specType)
|
|
63
63
|
|
|
64
|
-
if (args['--
|
|
65
|
-
// counts the number of tests for each tag across all specs
|
|
66
|
-
const { jsonResults, tagTestCounts } = getTests(specs, {
|
|
67
|
-
tags: args['--tags'],
|
|
68
|
-
tagged: args['--tagged'],
|
|
69
|
-
skipped: args['--skipped'],
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
if (args['--names']) {
|
|
73
|
-
if (args['--count']) {
|
|
74
|
-
let n = 0
|
|
75
|
-
Object.keys(jsonResults).forEach((filename) => {
|
|
76
|
-
const skippedCount = jsonResults[filename].counts.pending
|
|
77
|
-
n += skippedCount
|
|
78
|
-
})
|
|
79
|
-
console.log(n)
|
|
80
|
-
} else {
|
|
81
|
-
if (args['--json']) {
|
|
82
|
-
console.log(JSON.stringify(jsonResults, null, 2))
|
|
83
|
-
} else {
|
|
84
|
-
const str = stringAllInfo(jsonResults)
|
|
85
|
-
console.log(str)
|
|
86
|
-
}
|
|
87
|
-
console.log('')
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (args['--tags']) {
|
|
92
|
-
const tagEntries = Object.entries(tagTestCounts)
|
|
93
|
-
const sortedTagEntries = tagEntries.sort((a, b) => {
|
|
94
|
-
// every entry is [tag, count], so compare the tags
|
|
95
|
-
return a[0].localeCompare(b[0])
|
|
96
|
-
})
|
|
97
|
-
if (args['--json']) {
|
|
98
|
-
// assemble a json object with the tag counts
|
|
99
|
-
const tagResults = Object.fromEntries(sortedTagEntries)
|
|
100
|
-
console.log(JSON.stringify(tagResults, null, 2))
|
|
101
|
-
} else {
|
|
102
|
-
const table = consoleTable.getTable(['Tag', 'Tests'], sortedTagEntries)
|
|
103
|
-
console.log(table)
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (!args['--names'] && !args['--tags']) {
|
|
108
|
-
const specs = Object.keys(jsonResults)
|
|
109
|
-
if (args['--count']) {
|
|
110
|
-
debug('printing the number of specs %d', specs.length)
|
|
111
|
-
console.log(specs.length)
|
|
112
|
-
} else {
|
|
113
|
-
debug('printing the spec names list only')
|
|
114
|
-
const specNames = specs.join(',')
|
|
115
|
-
console.log(specNames)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
} else if (args['--branch']) {
|
|
64
|
+
if (args['--branch']) {
|
|
119
65
|
debug('determining specs changed against branch %s', args['--branch'])
|
|
120
66
|
let changedFiles = findChangedFiles(args['--branch'], args['--parent'])
|
|
121
67
|
debug('changed files %o', changedFiles)
|
|
@@ -211,6 +157,60 @@ if (args['--names'] || args['--tags'] || args['--tagged']) {
|
|
|
211
157
|
} else {
|
|
212
158
|
console.log(changedSpecs.join(','))
|
|
213
159
|
}
|
|
160
|
+
} else if (args['--names'] || args['--tags'] || args['--tagged']) {
|
|
161
|
+
// counts the number of tests for each tag across all specs
|
|
162
|
+
const { jsonResults, tagTestCounts } = getTests(specs, {
|
|
163
|
+
tags: args['--tags'],
|
|
164
|
+
tagged: args['--tagged'],
|
|
165
|
+
skipped: args['--skipped'],
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
if (args['--names']) {
|
|
169
|
+
if (args['--count']) {
|
|
170
|
+
let n = 0
|
|
171
|
+
Object.keys(jsonResults).forEach((filename) => {
|
|
172
|
+
const skippedCount = jsonResults[filename].counts.pending
|
|
173
|
+
n += skippedCount
|
|
174
|
+
})
|
|
175
|
+
console.log(n)
|
|
176
|
+
} else {
|
|
177
|
+
if (args['--json']) {
|
|
178
|
+
console.log(JSON.stringify(jsonResults, null, 2))
|
|
179
|
+
} else {
|
|
180
|
+
const str = stringAllInfo(jsonResults)
|
|
181
|
+
console.log(str)
|
|
182
|
+
}
|
|
183
|
+
console.log('')
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (args['--tags']) {
|
|
188
|
+
const tagEntries = Object.entries(tagTestCounts)
|
|
189
|
+
const sortedTagEntries = tagEntries.sort((a, b) => {
|
|
190
|
+
// every entry is [tag, count], so compare the tags
|
|
191
|
+
return a[0].localeCompare(b[0])
|
|
192
|
+
})
|
|
193
|
+
if (args['--json']) {
|
|
194
|
+
// assemble a json object with the tag counts
|
|
195
|
+
const tagResults = Object.fromEntries(sortedTagEntries)
|
|
196
|
+
console.log(JSON.stringify(tagResults, null, 2))
|
|
197
|
+
} else {
|
|
198
|
+
const table = consoleTable.getTable(['Tag', 'Tests'], sortedTagEntries)
|
|
199
|
+
console.log(table)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!args['--names'] && !args['--tags']) {
|
|
204
|
+
const specs = Object.keys(jsonResults)
|
|
205
|
+
if (args['--count']) {
|
|
206
|
+
debug('printing the number of specs %d', specs.length)
|
|
207
|
+
console.log(specs.length)
|
|
208
|
+
} else {
|
|
209
|
+
debug('printing the spec names list only')
|
|
210
|
+
const specNames = specs.join(',')
|
|
211
|
+
console.log(specNames)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
214
|
} else {
|
|
215
215
|
if (args['--count']) {
|
|
216
216
|
debug('printing the number of specs %d', specs.length)
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -295,8 +295,11 @@ function findChangedFiles(branch, useParent) {
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
// can we find updated and added files?
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
debug(
|
|
299
|
+
'finding changed files against %s using parent?',
|
|
300
|
+
branch,
|
|
301
|
+
Boolean(useParent),
|
|
302
|
+
)
|
|
300
303
|
|
|
301
304
|
if (useParent) {
|
|
302
305
|
let result = shell.exec(`git merge-base origin/${branch} HEAD`, {
|