find-cypress-specs 1.13.0 → 1.14.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 +8 -0
- package/bin/find.js +8 -5
- package/package.json +1 -1
- package/src/tagged.js +22 -4
package/README.md
CHANGED
|
@@ -77,6 +77,14 @@ $ npx find-cypress-specs --names --tagged <single tag>
|
|
|
77
77
|
# finds all specs and tests, then filters the output by a single tag
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
## Test names filtered by multiple tags
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
$ npx find-cypress-specs --names --tagged <tag1>,<tag2>,<tag3>,...
|
|
84
|
+
# finds all specs and tests, then filters the output showing all tests
|
|
85
|
+
# tagged with tag1 or tag2 or tag3 or ...
|
|
86
|
+
```
|
|
87
|
+
|
|
80
88
|
## Details
|
|
81
89
|
|
|
82
90
|
Cypress uses the resolved [configuration values](https://on.cypress.io/configuration) to find the spec files to run. It searches the `integrationFolder` for all patterns listed in `testFiles` and removes any files matching the `ignoreTestFiles` patterns.
|
package/bin/find.js
CHANGED
|
@@ -7,8 +7,7 @@ const { addCounts } = require('../src/count')
|
|
|
7
7
|
const { stringAllInfo } = require('../src/print')
|
|
8
8
|
|
|
9
9
|
const fs = require('fs')
|
|
10
|
-
const
|
|
11
|
-
const { getTestNames, formatTestList, countTags } = require('find-test-names')
|
|
10
|
+
const { getTestNames, countTags } = require('find-test-names')
|
|
12
11
|
const consoleTable = require('console.table')
|
|
13
12
|
const debug = require('debug')('find-cypress-specs')
|
|
14
13
|
|
|
@@ -74,9 +73,13 @@ if (args['--names'] || args['--tags']) {
|
|
|
74
73
|
|
|
75
74
|
if (args['--names']) {
|
|
76
75
|
if (args['--tagged']) {
|
|
77
|
-
// filter all collected tests to those that have the given tag
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
// filter all collected tests to those that have the given tag(s)
|
|
77
|
+
const splitTags = args['--tagged']
|
|
78
|
+
.split(',')
|
|
79
|
+
.map((s) => s.trim())
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
debug('filtering all tests by tag "%o"', splitTags)
|
|
82
|
+
pickTaggedTestsFrom(jsonResults, splitTags)
|
|
80
83
|
// recompute the number of tests
|
|
81
84
|
addCounts(jsonResults)
|
|
82
85
|
}
|
package/package.json
CHANGED
package/src/tagged.js
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
const { addCounts } = require('./count')
|
|
2
2
|
|
|
3
|
+
function arraysOverlap(a, b) {
|
|
4
|
+
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
5
|
+
return false
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (a.length < b.length) {
|
|
9
|
+
return a.some((item) => b.includes(item))
|
|
10
|
+
} else {
|
|
11
|
+
return b.some((item) => a.includes(item))
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
// note: modifies the tests in place
|
|
4
16
|
function pickTaggedTests(tests, tag) {
|
|
5
17
|
if (!Array.isArray(tests)) {
|
|
6
18
|
return false
|
|
7
19
|
}
|
|
20
|
+
const tags = Array.isArray(tag) ? tag : [tag]
|
|
8
21
|
const filteredTests = tests.filter((test) => {
|
|
9
22
|
if (test.type === 'test') {
|
|
10
|
-
return test.tags && test.tags
|
|
23
|
+
return test.tags && arraysOverlap(test.tags, tags)
|
|
11
24
|
} else if (test.type === 'suite') {
|
|
12
|
-
if (test.tags && test.tags
|
|
25
|
+
if (test.tags && arraysOverlap(test.tags, tags)) {
|
|
13
26
|
return true
|
|
14
27
|
}
|
|
15
28
|
|
|
16
29
|
// maybe there is some test inside this suite
|
|
17
30
|
// with the tag? Filter all other tests
|
|
18
31
|
return (
|
|
19
|
-
pickTaggedTests(test.tests,
|
|
32
|
+
pickTaggedTests(test.tests, tags) || pickTaggedTests(test.suites, tags)
|
|
20
33
|
)
|
|
21
34
|
}
|
|
22
35
|
})
|
|
@@ -51,4 +64,9 @@ function pickTaggedTestsFrom(json, tag) {
|
|
|
51
64
|
return result
|
|
52
65
|
}
|
|
53
66
|
|
|
54
|
-
module.exports = {
|
|
67
|
+
module.exports = {
|
|
68
|
+
arraysOverlap,
|
|
69
|
+
pickTaggedTestsFrom,
|
|
70
|
+
removeEmptyNodes,
|
|
71
|
+
pickTaggedTests,
|
|
72
|
+
}
|