find-cypress-specs 1.33.3 → 1.34.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 +4 -2
- package/bin/find.js +6 -0
- package/package.json +5 -4
- package/src/index.js +12 -0
- package/src/tagged.js +16 -2
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
|
|
|
@@ -143,7 +143,9 @@ cypress/e2e/featureA/user.js (2 tests, 1 pending)
|
|
|
143
143
|
found 2 specs (4 tests, 1 pending)
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
Where the tags are listed inside `[ ... ]` (see [
|
|
146
|
+
Where the tags are listed inside `[ ... ]` (see [@bahmutov/cy-grep](https://github.com/bahmutov/cy-grep)) and the [pending tests](https://glebbahmutov.com/blog/cypress-test-statuses/) are marked with `⊙` character.
|
|
147
|
+
|
|
148
|
+
Required tags are marked with `[[ ... ]]`.
|
|
147
149
|
|
|
148
150
|
You can print the results in JSON format using `--json` or `-j` option.
|
|
149
151
|
|
package/bin/find.js
CHANGED
|
@@ -169,6 +169,7 @@ if (args['--test-counts']) {
|
|
|
169
169
|
const source = fs.readFileSync(file, 'utf8')
|
|
170
170
|
const result = getTestNames(source, true)
|
|
171
171
|
const specTagCounts = countTags(result.structure)
|
|
172
|
+
// debug(specTagCounts)
|
|
172
173
|
const specHasTags = Object.keys(specTagCounts).some((tag) =>
|
|
173
174
|
splitTags.includes(tag),
|
|
174
175
|
)
|
|
@@ -197,9 +198,14 @@ if (args['--test-counts']) {
|
|
|
197
198
|
tagged: args['--tagged'],
|
|
198
199
|
skipped: args['--skipped'],
|
|
199
200
|
})
|
|
201
|
+
debug('json results from getTests')
|
|
202
|
+
debug(jsonResults)
|
|
203
|
+
debug('tag test counts')
|
|
204
|
+
debug(tagTestCounts)
|
|
200
205
|
|
|
201
206
|
if (args['--names']) {
|
|
202
207
|
if (args['--count']) {
|
|
208
|
+
debug('names and count')
|
|
203
209
|
let n = 0
|
|
204
210
|
Object.keys(jsonResults).forEach((filename) => {
|
|
205
211
|
const skippedCount = jsonResults[filename].counts.pending
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cypress-specs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.0",
|
|
4
4
|
"description": "Find Cypress spec files using the config settings",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"files": [
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"deps-changed": "DEBUG=find-cypress-specs node ./bin/find --branch main --parent --trace-imports cypress --time-trace --cache-trace",
|
|
34
34
|
"demo-component": "DEBUG=find-cypress-specs node ./bin/find --component --names",
|
|
35
35
|
"demo-exclusive": "npm run test-names --prefix test-exclusive --silent",
|
|
36
|
-
"version-badge": "update-badge cypress"
|
|
36
|
+
"version-badge": "update-badge cypress",
|
|
37
|
+
"count-all-tags": "npm run count-all-tags --prefix test-required-tags"
|
|
37
38
|
},
|
|
38
39
|
"repository": {
|
|
39
40
|
"type": "git",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"homepage": "https://github.com/bahmutov/find-cypress-specs#readme",
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"ava": "^4.0.0",
|
|
53
|
-
"cypress": "12.
|
|
54
|
+
"cypress": "12.13.0",
|
|
54
55
|
"dependency-version-badge": "^1.11.0",
|
|
55
56
|
"execa-wrap": "^1.4.0",
|
|
56
57
|
"prettier": "^2.5.1",
|
|
@@ -64,7 +65,7 @@
|
|
|
64
65
|
"arg": "^5.0.1",
|
|
65
66
|
"console.table": "^0.10.0",
|
|
66
67
|
"debug": "^4.3.3",
|
|
67
|
-
"find-test-names": "1.28.
|
|
68
|
+
"find-test-names": "1.28.8",
|
|
68
69
|
"globby": "^11.0.4",
|
|
69
70
|
"minimatch": "^3.0.4",
|
|
70
71
|
"pluralize": "^8.0.0",
|
package/src/index.js
CHANGED
|
@@ -254,6 +254,7 @@ function collectResults(structure, results) {
|
|
|
254
254
|
name: t.name,
|
|
255
255
|
type: t.type,
|
|
256
256
|
tags: t.tags,
|
|
257
|
+
requiredTags: t.requiredTags,
|
|
257
258
|
}
|
|
258
259
|
if (t.pending) {
|
|
259
260
|
info.pending = t.pending
|
|
@@ -261,6 +262,9 @@ function collectResults(structure, results) {
|
|
|
261
262
|
if (t.exclusive) {
|
|
262
263
|
info.exclusive = t.exclusive
|
|
263
264
|
}
|
|
265
|
+
debug('structure for %s', t.name)
|
|
266
|
+
debug(info)
|
|
267
|
+
|
|
264
268
|
results.push(info)
|
|
265
269
|
if (t.type === 'suite') {
|
|
266
270
|
if (t.suites && t.suites.length) {
|
|
@@ -382,9 +386,14 @@ function getTests(specs, options = {}) {
|
|
|
382
386
|
// enable if need to debug the parsed test
|
|
383
387
|
// console.dir(result.structure, { depth: null })
|
|
384
388
|
collectResults(result.structure, jsonResults[filename].tests)
|
|
389
|
+
debug('collected results for file %s', filename)
|
|
385
390
|
|
|
386
391
|
if (tags) {
|
|
392
|
+
debug('counting tags', tags)
|
|
387
393
|
const specTagCounts = countTags(result.structure)
|
|
394
|
+
debug('spec tag counts')
|
|
395
|
+
debug(specTagCounts)
|
|
396
|
+
|
|
388
397
|
Object.keys(specTagCounts).forEach((tag) => {
|
|
389
398
|
if (!(tag in tagTestCounts)) {
|
|
390
399
|
tagTestCounts[tag] = specTagCounts[tag]
|
|
@@ -400,6 +409,8 @@ function getTests(specs, options = {}) {
|
|
|
400
409
|
})
|
|
401
410
|
|
|
402
411
|
addCounts(jsonResults)
|
|
412
|
+
debug('added counts')
|
|
413
|
+
debug(jsonResults)
|
|
403
414
|
|
|
404
415
|
if (tagged) {
|
|
405
416
|
// filter all collected tests to those that have the given tag(s)
|
|
@@ -409,6 +420,7 @@ function getTests(specs, options = {}) {
|
|
|
409
420
|
.filter(Boolean)
|
|
410
421
|
debug('filtering all tests by tag %o', splitTags)
|
|
411
422
|
pickTaggedTestsFrom(jsonResults, splitTags)
|
|
423
|
+
// debug(jsonResults)
|
|
412
424
|
// recompute the number of tests
|
|
413
425
|
addCounts(jsonResults)
|
|
414
426
|
} else if (skipped) {
|
package/src/tagged.js
CHANGED
|
@@ -12,6 +12,18 @@ function arraysOverlap(a, b) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function combineTags(tags, requiredTags) {
|
|
16
|
+
if (tags && requiredTags) {
|
|
17
|
+
return [].concat(tags).concat(requiredTags)
|
|
18
|
+
}
|
|
19
|
+
if (tags) {
|
|
20
|
+
return [...tags]
|
|
21
|
+
}
|
|
22
|
+
if (requiredTags) {
|
|
23
|
+
return [...requiredTags]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
// note: modifies the tests in place
|
|
16
28
|
function pickTaggedTests(tests, tag) {
|
|
17
29
|
if (!Array.isArray(tests)) {
|
|
@@ -20,9 +32,11 @@ function pickTaggedTests(tests, tag) {
|
|
|
20
32
|
const tags = Array.isArray(tag) ? tag : [tag]
|
|
21
33
|
const filteredTests = tests.filter((test) => {
|
|
22
34
|
if (test.type === 'test') {
|
|
23
|
-
|
|
35
|
+
const allTags = combineTags(test.tags, test.requiredTags)
|
|
36
|
+
return allTags && arraysOverlap(allTags, tags)
|
|
24
37
|
} else if (test.type === 'suite') {
|
|
25
|
-
|
|
38
|
+
const allTags = combineTags(test.tags, test.requiredTags)
|
|
39
|
+
if (allTags && arraysOverlap(test.tags, tags)) {
|
|
26
40
|
return true
|
|
27
41
|
}
|
|
28
42
|
|