find-cypress-specs 1.4.0 → 1.5.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 +14 -0
- package/bin/find.js +30 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -31,6 +31,20 @@ found 2 specs (4 tests, 1 pending)
|
|
|
31
31
|
|
|
32
32
|
Where the tags are listed inside `[ ... ]` (see [cypress-grep](https://github.com/cypress-io/cypress-grep)) and the [pending tests](https://glebbahmutov.com/blog/cypress-test-statuses/) are marked with `⊙` character.
|
|
33
33
|
|
|
34
|
+
## Test tags
|
|
35
|
+
|
|
36
|
+
You can count tags attached to the individual tests using `--names --tags` arguments
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
$ npx find-cypress-specs --names --tags
|
|
40
|
+
# prints the specs and tests and at the end prints the tags table
|
|
41
|
+
|
|
42
|
+
Tag Test count
|
|
43
|
+
----- ----------
|
|
44
|
+
@user 2
|
|
45
|
+
@sign 1
|
|
46
|
+
```
|
|
47
|
+
|
|
34
48
|
## Details
|
|
35
49
|
|
|
36
50
|
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
|
@@ -4,13 +4,18 @@ const arg = require('arg')
|
|
|
4
4
|
const { getSpecs } = require('../src')
|
|
5
5
|
const fs = require('fs')
|
|
6
6
|
const pluralize = require('pluralize')
|
|
7
|
-
const { getTestNames, formatTestList } = require('find-test-names')
|
|
7
|
+
const { getTestNames, formatTestList, countTags } = require('find-test-names')
|
|
8
|
+
const consoleTable = require('console.table')
|
|
8
9
|
|
|
9
10
|
const args = arg({
|
|
10
11
|
'--names': Boolean,
|
|
12
|
+
'--tags': Boolean,
|
|
11
13
|
|
|
12
14
|
// aliases
|
|
13
15
|
'-n': '--names',
|
|
16
|
+
'--name': '--names',
|
|
17
|
+
'-t': '--tags',
|
|
18
|
+
'--tag': '--tags',
|
|
14
19
|
})
|
|
15
20
|
|
|
16
21
|
const specs = getSpecs()
|
|
@@ -21,6 +26,10 @@ if (args['--names']) {
|
|
|
21
26
|
console.log('')
|
|
22
27
|
let testsN = 0
|
|
23
28
|
let pendingTestsN = 0
|
|
29
|
+
|
|
30
|
+
// counts the number of tests for each tag across all specs
|
|
31
|
+
const tagTestCounts = {}
|
|
32
|
+
|
|
24
33
|
specs.forEach((filename) => {
|
|
25
34
|
const source = fs.readFileSync(filename, 'utf8')
|
|
26
35
|
const result = getTestNames(source, true)
|
|
@@ -43,6 +52,17 @@ if (args['--names']) {
|
|
|
43
52
|
}
|
|
44
53
|
console.log(formatTestList(result.structure))
|
|
45
54
|
console.log('')
|
|
55
|
+
|
|
56
|
+
if (args['--tags']) {
|
|
57
|
+
const specTagCounts = countTags(result.structure)
|
|
58
|
+
Object.keys(specTagCounts).forEach((tag) => {
|
|
59
|
+
if (!(tag in tagTestCounts)) {
|
|
60
|
+
tagTestCounts[tag] = specTagCounts[tag]
|
|
61
|
+
} else {
|
|
62
|
+
tagTestCounts[tag] += specTagCounts[tag]
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}
|
|
46
66
|
})
|
|
47
67
|
|
|
48
68
|
if (pendingTestsN) {
|
|
@@ -60,6 +80,15 @@ if (args['--names']) {
|
|
|
60
80
|
)
|
|
61
81
|
}
|
|
62
82
|
console.log('')
|
|
83
|
+
|
|
84
|
+
if (args['--tags']) {
|
|
85
|
+
const table = consoleTable.getTable(
|
|
86
|
+
['Tag', 'Test count'],
|
|
87
|
+
Object.entries(tagTestCounts),
|
|
88
|
+
)
|
|
89
|
+
console.log(table)
|
|
90
|
+
console.log('')
|
|
91
|
+
}
|
|
63
92
|
}
|
|
64
93
|
} else {
|
|
65
94
|
console.log(specs.join(','))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cypress-specs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Find Cypress spec files using the config settings",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"files": [
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"cy:run": "DEBUG=cypress:cli,cypress:server:specs cypress run",
|
|
16
16
|
"demo": "DEBUG=find-cypress-specs node ./bin/find",
|
|
17
17
|
"demo-names": "node ./bin/find --names",
|
|
18
|
+
"demo-tags": "node ./bin/find --names --tags",
|
|
18
19
|
"semantic-release": "semantic-release"
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
@@ -38,8 +39,9 @@
|
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"arg": "^5.0.1",
|
|
42
|
+
"console.table": "^0.10.0",
|
|
41
43
|
"debug": "^4.3.3",
|
|
42
|
-
"find-test-names": "^1.
|
|
44
|
+
"find-test-names": "^1.13.0",
|
|
43
45
|
"globby": "^11.0.4",
|
|
44
46
|
"minimatch": "^3.0.4",
|
|
45
47
|
"pluralize": "^8.0.0"
|