find-cypress-specs 1.31.0 → 1.31.2

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 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['--names'] || args['--tags'] || args['--tagged']) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-cypress-specs",
3
- "version": "1.31.0",
3
+ "version": "1.31.2",
4
4
  "description": "Find Cypress spec files using the config settings",
5
5
  "main": "src",
6
6
  "files": [
@@ -47,11 +47,11 @@
47
47
  "homepage": "https://github.com/bahmutov/find-cypress-specs#readme",
48
48
  "devDependencies": {
49
49
  "ava": "^4.0.0",
50
- "cypress": "12.8.0",
50
+ "cypress": "12.8.1",
51
51
  "execa-wrap": "^1.4.0",
52
52
  "prettier": "^2.5.1",
53
53
  "really-need": "^1.9.2",
54
- "semantic-release": "20.1.1",
54
+ "semantic-release": "20.1.3",
55
55
  "sinon": "^13.0.1",
56
56
  "typescript": "^4.6.3"
57
57
  },
@@ -60,7 +60,7 @@
60
60
  "arg": "^5.0.1",
61
61
  "console.table": "^0.10.0",
62
62
  "debug": "^4.3.3",
63
- "find-test-names": "1.28.1",
63
+ "find-test-names": "1.28.3",
64
64
  "globby": "^11.0.4",
65
65
  "minimatch": "^3.0.4",
66
66
  "pluralize": "^8.0.0",
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
- debugGit('finding changed files against %s', branch)
299
- debugGit('using parent?', useParent)
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`, {