find-cypress-specs 1.2.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 +19 -3
- package/bin/find.js +60 -2
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -16,19 +16,35 @@ You can print each spec file with the suite and test names inside of it (found u
|
|
|
16
16
|
$ npx find-cypress-specs --names
|
|
17
17
|
# prints something like
|
|
18
18
|
|
|
19
|
-
cypress/e2e/spec.js
|
|
19
|
+
cypress/e2e/spec.js (2 tests)
|
|
20
20
|
└─ parent suite [@main]
|
|
21
|
-
├─ works
|
|
21
|
+
├─ works well enough
|
|
22
22
|
└─ inner suite
|
|
23
23
|
└─ shows something [@user]
|
|
24
24
|
|
|
25
|
-
cypress/e2e/featureA/user.js
|
|
25
|
+
cypress/e2e/featureA/user.js (2 tests, 1 pending)
|
|
26
26
|
├─ works
|
|
27
27
|
└⊙ needs to be written
|
|
28
|
+
|
|
29
|
+
found 2 specs (4 tests, 1 pending)
|
|
28
30
|
```
|
|
29
31
|
|
|
30
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.
|
|
31
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
|
+
|
|
32
48
|
## Details
|
|
33
49
|
|
|
34
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()
|
|
@@ -19,18 +24,71 @@ if (args['--names']) {
|
|
|
19
24
|
console.log('no specs found')
|
|
20
25
|
} else {
|
|
21
26
|
console.log('')
|
|
27
|
+
let testsN = 0
|
|
28
|
+
let pendingTestsN = 0
|
|
29
|
+
|
|
30
|
+
// counts the number of tests for each tag across all specs
|
|
31
|
+
const tagTestCounts = {}
|
|
32
|
+
|
|
22
33
|
specs.forEach((filename) => {
|
|
23
34
|
const source = fs.readFileSync(filename, 'utf8')
|
|
24
35
|
const result = getTestNames(source, true)
|
|
25
36
|
// enable if need to debug the parsed test
|
|
26
37
|
// console.dir(result.structure, { depth: null })
|
|
27
38
|
|
|
39
|
+
testsN += result.testCount
|
|
28
40
|
const testCount = pluralize('test', result.testNames.length, true)
|
|
41
|
+
pendingTestsN += result.pendingTestCount
|
|
29
42
|
|
|
30
|
-
|
|
43
|
+
if (result.pendingTestCount) {
|
|
44
|
+
console.log(
|
|
45
|
+
'%s (%s, %d pending)',
|
|
46
|
+
filename,
|
|
47
|
+
testCount,
|
|
48
|
+
result.pendingTestCount,
|
|
49
|
+
)
|
|
50
|
+
} else {
|
|
51
|
+
console.log('%s (%s)', filename, testCount)
|
|
52
|
+
}
|
|
31
53
|
console.log(formatTestList(result.structure))
|
|
32
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
|
+
}
|
|
33
66
|
})
|
|
67
|
+
|
|
68
|
+
if (pendingTestsN) {
|
|
69
|
+
console.log(
|
|
70
|
+
'found %s (%s, %d pending)',
|
|
71
|
+
pluralize('spec', specs.length, true),
|
|
72
|
+
pluralize('test', testsN, true),
|
|
73
|
+
pendingTestsN,
|
|
74
|
+
)
|
|
75
|
+
} else {
|
|
76
|
+
console.log(
|
|
77
|
+
'found %s (%s)',
|
|
78
|
+
pluralize('spec', specs.length, true),
|
|
79
|
+
pluralize('test', testsN, true),
|
|
80
|
+
)
|
|
81
|
+
}
|
|
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
|
+
}
|
|
34
92
|
}
|
|
35
93
|
} else {
|
|
36
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"
|