find-cypress-specs 1.30.1 → 1.31.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 +24 -1
- package/bin/find.js +16 -5
- package/package.json +2 -2
- package/src/index.js +14 -8
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# find-cypress-specs [![renovate-app badge][renovate-badge]][renovate-app]  [](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml)
|
|
2
2
|
|
|
3
3
|
> Find Cypress spec files using the config settings
|
|
4
4
|
|
|
@@ -10,6 +10,15 @@ cypress/e2e/spec.js,cypress/e2e/featureA/user.js
|
|
|
10
10
|
|
|
11
11
|
Supports JS and TS specs
|
|
12
12
|
|
|
13
|
+
## Count
|
|
14
|
+
|
|
15
|
+
You can count the number of specs found
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ npx find-cypress-specs --count
|
|
19
|
+
2
|
|
20
|
+
```
|
|
21
|
+
|
|
13
22
|
## Component specs
|
|
14
23
|
|
|
15
24
|
By default, it finds the E2E specs and tests. You can find component specs using `--component` CLI option
|
|
@@ -159,6 +168,7 @@ $ npx find-cypress-specs --names --tagged <tag1>,<tag2>,<tag3>,...
|
|
|
159
168
|
# finds all specs and tests, then filters the output showing all tests
|
|
160
169
|
# tagged with tag1 or tag2 or tag3 or ...
|
|
161
170
|
```
|
|
171
|
+
|
|
162
172
|
## File names filtered by a tag
|
|
163
173
|
|
|
164
174
|
```
|
|
@@ -169,6 +179,13 @@ $ npx find-cypress-specs --tagged <single tag>
|
|
|
169
179
|
# cypress/e2e/spec.cy.js,cypress/e2e/featureA/user.cy.ts
|
|
170
180
|
```
|
|
171
181
|
|
|
182
|
+
You can print the number of found tagged specs by adding `--count` argument
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
$ npx find-cypress-specs --tagged <single tag>
|
|
186
|
+
3
|
|
187
|
+
```
|
|
188
|
+
|
|
172
189
|
## File names filtered by multiple tags
|
|
173
190
|
|
|
174
191
|
```
|
|
@@ -257,6 +274,12 @@ Finding tests in the individual specs uses [find-test-names](https://github.com/
|
|
|
257
274
|
$ DEBUG=find-cypress-specs,find-test-names npx find-cypress-specs --names
|
|
258
275
|
```
|
|
259
276
|
|
|
277
|
+
To debug finding changed specs against a branch, use `find-cypress-specs:git`
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
$ DEBUG=find-cypress-specs:git npx find-cypress-specs --branch main
|
|
281
|
+
```
|
|
282
|
+
|
|
260
283
|
## Videos
|
|
261
284
|
|
|
262
285
|
- [Use Ava Snapshots And Execa-wrap To Write End-to-End Tests For CLI Utilities](https://youtu.be/rsw17RqP0G0)
|
package/bin/find.js
CHANGED
|
@@ -105,9 +105,15 @@ if (args['--names'] || args['--tags'] || args['--tagged']) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
if (!args['--names'] && !args['--tags']) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
+
}
|
|
111
117
|
}
|
|
112
118
|
} else if (args['--branch']) {
|
|
113
119
|
debug('determining specs changed against branch %s', args['--branch'])
|
|
@@ -206,6 +212,11 @@ if (args['--names'] || args['--tags'] || args['--tagged']) {
|
|
|
206
212
|
console.log(changedSpecs.join(','))
|
|
207
213
|
}
|
|
208
214
|
} else {
|
|
209
|
-
|
|
210
|
-
|
|
215
|
+
if (args['--count']) {
|
|
216
|
+
debug('printing the number of specs %d', specs.length)
|
|
217
|
+
console.log(specs.length)
|
|
218
|
+
} else {
|
|
219
|
+
debug('printing just %d spec names', specs.length)
|
|
220
|
+
console.log(specs.join(','))
|
|
221
|
+
}
|
|
211
222
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cypress-specs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "Find Cypress spec files using the config settings",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"files": [
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"homepage": "https://github.com/bahmutov/find-cypress-specs#readme",
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"ava": "^4.0.0",
|
|
50
|
-
"cypress": "12.
|
|
50
|
+
"cypress": "12.8.0",
|
|
51
51
|
"execa-wrap": "^1.4.0",
|
|
52
52
|
"prettier": "^2.5.1",
|
|
53
53
|
"really-need": "^1.9.2",
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const { getTestNames, countTags } = require('find-test-names')
|
|
|
3
3
|
const { pickTaggedTestsFrom, leavePendingTestsOnly } = require('../src/tagged')
|
|
4
4
|
|
|
5
5
|
const debug = require('debug')('find-cypress-specs')
|
|
6
|
+
const debugGit = require('debug')('find-cypress-specs:git')
|
|
6
7
|
const fs = require('fs')
|
|
7
8
|
const path = require('path')
|
|
8
9
|
const globby = require('globby')
|
|
@@ -294,25 +295,25 @@ function findChangedFiles(branch, useParent) {
|
|
|
294
295
|
}
|
|
295
296
|
|
|
296
297
|
// can we find updated and added files?
|
|
297
|
-
|
|
298
|
-
|
|
298
|
+
debugGit('finding changed files against %s', branch)
|
|
299
|
+
debugGit('using parent?', useParent)
|
|
299
300
|
|
|
300
301
|
if (useParent) {
|
|
301
302
|
let result = shell.exec(`git merge-base origin/${branch} HEAD`, {
|
|
302
303
|
silent: true,
|
|
303
304
|
})
|
|
304
305
|
if (result.code !== 0) {
|
|
305
|
-
|
|
306
|
+
debugGit('git failed to find merge base with the branch %s', branch)
|
|
306
307
|
return []
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
const commit = result.stdout.trim()
|
|
310
|
-
|
|
311
|
+
debugGit('merge commit with branch "%s" is %s', branch, commit)
|
|
311
312
|
result = shell.exec(`git diff --name-only --diff-filter=AMR ${commit}..`, {
|
|
312
313
|
silent: true,
|
|
313
314
|
})
|
|
314
315
|
if (result.code !== 0) {
|
|
315
|
-
|
|
316
|
+
debugGit('git diff failed with code %d', result.code)
|
|
316
317
|
return []
|
|
317
318
|
}
|
|
318
319
|
|
|
@@ -320,14 +321,19 @@ function findChangedFiles(branch, useParent) {
|
|
|
320
321
|
.split('\n')
|
|
321
322
|
.map((s) => s.trim())
|
|
322
323
|
.filter(Boolean)
|
|
324
|
+
debugGit(
|
|
325
|
+
'found %d changed files against branch %s',
|
|
326
|
+
filenames.length,
|
|
327
|
+
branch,
|
|
328
|
+
)
|
|
323
329
|
return filenames
|
|
324
330
|
} else {
|
|
325
331
|
const command = `git diff --name-only --diff-filter=AMR origin/${branch}`
|
|
326
|
-
|
|
332
|
+
debugGit('command: %s', command)
|
|
327
333
|
|
|
328
334
|
const result = shell.exec(command, { silent: true })
|
|
329
335
|
if (result.code !== 0) {
|
|
330
|
-
|
|
336
|
+
debugGit('git diff failed with code %d', result.code)
|
|
331
337
|
return []
|
|
332
338
|
}
|
|
333
339
|
|
|
@@ -335,7 +341,7 @@ function findChangedFiles(branch, useParent) {
|
|
|
335
341
|
.split('\n')
|
|
336
342
|
.map((s) => s.trim())
|
|
337
343
|
.filter(Boolean)
|
|
338
|
-
|
|
344
|
+
debugGit(
|
|
339
345
|
'found %d changed %s',
|
|
340
346
|
filenames.length,
|
|
341
347
|
pluralize('file', filenames.length),
|