find-cypress-specs 1.29.4 → 1.30.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 +17 -0
- package/bin/find.js +9 -2
- package/package.json +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
|
@@ -60,8 +60,15 @@ debug('arguments %o', args)
|
|
|
60
60
|
const specType = args['--component'] ? 'component' : 'e2e'
|
|
61
61
|
|
|
62
62
|
const specs = getSpecs(undefined, specType)
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
if (args['--tagged']) {
|
|
64
|
+
const { jsonResults, tagTestCounts } = getTests(specs, {
|
|
65
|
+
tags: args['--tags'],
|
|
66
|
+
tagged: args['--tagged'],
|
|
67
|
+
skipped: args['--skipped'],
|
|
68
|
+
})
|
|
69
|
+
const str = stringAllInfo(jsonResults, true)
|
|
70
|
+
console.log(str)
|
|
71
|
+
} else if (args['--names'] || args['--tags']) {
|
|
65
72
|
// counts the number of tests for each tag across all specs
|
|
66
73
|
const { jsonResults, tagTestCounts } = getTests(specs, {
|
|
67
74
|
tags: args['--tags'],
|
package/package.json
CHANGED
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
|
+
}
|