find-cypress-specs 1.29.4 → 1.30.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 +17 -0
- package/bin/find.js +8 -1
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/print.js +38 -23
package/README.md
CHANGED
|
@@ -159,6 +159,23 @@ $ npx find-cypress-specs --names --tagged <tag1>,<tag2>,<tag3>,...
|
|
|
159
159
|
# finds all specs and tests, then filters the output showing all tests
|
|
160
160
|
# tagged with tag1 or tag2 or tag3 or ...
|
|
161
161
|
```
|
|
162
|
+
## File names filtered by a tag
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
$ npx find-cypress-specs --tagged <single tag>
|
|
166
|
+
# finds all specs and tests, then filters the output showing only the file names associated with the tests
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# cypress/e2e/spec.cy.js,cypress/e2e/featureA/user.cy.ts
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## File names filtered by multiple tags
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
$ npx find-cypress-specs --tagged <tag1>,<tag2>,<tag3>,...
|
|
176
|
+
# finds all specs and tests, then filters the output showing only the file names associated with the tests
|
|
177
|
+
# tagged with tag1 or tag2 or tag3 or ...
|
|
178
|
+
```
|
|
162
179
|
|
|
163
180
|
## Show only the pending tests
|
|
164
181
|
|
package/bin/find.js
CHANGED
|
@@ -61,7 +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']) {
|
|
64
|
+
if (args['--names'] || args['--tags'] || args['--tagged']) {
|
|
65
65
|
// counts the number of tests for each tag across all specs
|
|
66
66
|
const { jsonResults, tagTestCounts } = getTests(specs, {
|
|
67
67
|
tags: args['--tags'],
|
|
@@ -103,6 +103,12 @@ if (args['--names'] || args['--tags']) {
|
|
|
103
103
|
console.log(table)
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
if (!args['--names'] && !args['--tags']) {
|
|
108
|
+
debug('printing the spec names list only')
|
|
109
|
+
const specNames = Object.keys(jsonResults).join(',')
|
|
110
|
+
console.log(specNames)
|
|
111
|
+
}
|
|
106
112
|
} else if (args['--branch']) {
|
|
107
113
|
debug('determining specs changed against branch %s', args['--branch'])
|
|
108
114
|
let changedFiles = findChangedFiles(args['--branch'], args['--parent'])
|
|
@@ -200,5 +206,6 @@ if (args['--names'] || args['--tags']) {
|
|
|
200
206
|
console.log(changedSpecs.join(','))
|
|
201
207
|
}
|
|
202
208
|
} else {
|
|
209
|
+
debug('printing just %d spec names', specs.length)
|
|
203
210
|
console.log(specs.join(','))
|
|
204
211
|
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -398,7 +398,7 @@ function getTests(specs, options = {}) {
|
|
|
398
398
|
.split(',')
|
|
399
399
|
.map((s) => s.trim())
|
|
400
400
|
.filter(Boolean)
|
|
401
|
-
debug('filtering all tests by tag
|
|
401
|
+
debug('filtering all tests by tag %o', splitTags)
|
|
402
402
|
pickTaggedTestsFrom(jsonResults, splitTags)
|
|
403
403
|
// recompute the number of tests
|
|
404
404
|
addCounts(jsonResults)
|
package/src/print.js
CHANGED
|
@@ -5,47 +5,62 @@ const { formatTestList } = require('find-test-names')
|
|
|
5
5
|
* Outputs a string representation of the json test results object,
|
|
6
6
|
* like a tree of suites and tests.
|
|
7
7
|
*/
|
|
8
|
-
function stringFileTests(fileName, fileInfo) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
function stringFileTests(fileName, fileInfo, tagged) {
|
|
9
|
+
if (tagged) {
|
|
10
|
+
const headerLine = fileName;
|
|
11
|
+
return headerLine
|
|
12
|
+
} else {
|
|
13
|
+
const testCount = pluralize('test', fileInfo.counts.tests, true)
|
|
14
|
+
const headerLine = fileInfo.counts.pending
|
|
15
|
+
? `${fileName} (${testCount}, ${fileInfo.counts.pending} pending)`
|
|
16
|
+
: `${fileName} (${testCount})`
|
|
17
|
+
|
|
18
|
+
// console.log(fileInfo.tests)
|
|
19
|
+
const body = formatTestList(fileInfo.tests)
|
|
20
|
+
|
|
21
|
+
return headerLine + '\n' + body + '\n'
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
function stringAllInfo(allInfo) {
|
|
25
|
+
function stringAllInfo(allInfo, tagged) {
|
|
21
26
|
let fileCount = 0
|
|
22
27
|
let testCount = 0
|
|
23
28
|
let pendingTestCount = 0
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
if (!tagged) {
|
|
31
|
+
const allInfoString = Object.keys(allInfo)
|
|
26
32
|
.map((fileName) => {
|
|
27
33
|
const fileInfo = allInfo[fileName]
|
|
28
34
|
fileCount += 1
|
|
29
35
|
testCount += fileInfo.counts.tests
|
|
30
36
|
pendingTestCount += fileInfo.counts.pending
|
|
31
|
-
return stringFileTests(fileName, fileInfo)
|
|
37
|
+
return stringFileTests(fileName, fileInfo, tagged)
|
|
32
38
|
})
|
|
33
39
|
.join('\n')
|
|
40
|
+
// footer line is something like
|
|
41
|
+
// found 2 specs (4 tests, 1 pending)
|
|
42
|
+
let footer = `found ${pluralize('spec', fileCount, true)}`
|
|
43
|
+
const testWord = pluralize('test', testCount, true)
|
|
44
|
+
if (pendingTestCount) {
|
|
45
|
+
footer += ` (${testWord}, ${pendingTestCount} pending)`
|
|
46
|
+
} else {
|
|
47
|
+
footer += ` (${testWord})`
|
|
48
|
+
}
|
|
34
49
|
|
|
35
|
-
|
|
36
|
-
// found 2 specs (4 tests, 1 pending)
|
|
37
|
-
let footer = `found ${pluralize('spec', fileCount, true)}`
|
|
38
|
-
const testWord = pluralize('test', testCount, true)
|
|
39
|
-
if (pendingTestCount) {
|
|
40
|
-
footer += ` (${testWord}, ${pendingTestCount} pending)`
|
|
50
|
+
return allInfoString + '\n' + footer
|
|
41
51
|
} else {
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
const allInfoString = Object.keys(allInfo)
|
|
53
|
+
.map((fileName) => {
|
|
54
|
+
const fileInfo = allInfo[fileName]
|
|
55
|
+
return stringFileTests(fileName, fileInfo, tagged)
|
|
56
|
+
})
|
|
57
|
+
.join(',')
|
|
44
58
|
|
|
45
|
-
|
|
59
|
+
return allInfoString
|
|
60
|
+
}
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
module.exports = {
|
|
49
64
|
stringFileTests,
|
|
50
65
|
stringAllInfo,
|
|
51
|
-
}
|
|
66
|
+
}
|