find-cypress-specs 1.7.0 → 1.8.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 +4 -0
- package/bin/find.js +41 -22
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -57,6 +57,10 @@ You can see how Cypress finds the specs using `DEBUG=cypress:cli,cypress:server:
|
|
|
57
57
|
|
|
58
58
|
Run the utility with environment variable `DEBUG=find-cypress-specs` to see the verbose logs
|
|
59
59
|
|
|
60
|
+
## Videos
|
|
61
|
+
|
|
62
|
+
- [Use Ava Snapshots And Execa-wrap To Write End-to-End Tests For CLI Utilities](https://youtu.be/rsw17RqP0G0)
|
|
63
|
+
|
|
60
64
|
## Small print
|
|
61
65
|
|
|
62
66
|
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2022
|
package/bin/find.js
CHANGED
|
@@ -10,12 +10,14 @@ const consoleTable = require('console.table')
|
|
|
10
10
|
const args = arg({
|
|
11
11
|
'--names': Boolean,
|
|
12
12
|
'--tags': Boolean,
|
|
13
|
+
'--json': Boolean,
|
|
13
14
|
|
|
14
15
|
// aliases
|
|
15
16
|
'-n': '--names',
|
|
16
17
|
'--name': '--names',
|
|
17
18
|
'-t': '--tags',
|
|
18
19
|
'--tag': '--tags',
|
|
20
|
+
'-j': '--json',
|
|
19
21
|
})
|
|
20
22
|
|
|
21
23
|
const specs = getSpecs()
|
|
@@ -30,7 +32,10 @@ if (args['--names'] || args['--tags']) {
|
|
|
30
32
|
// counts the number of tests for each tag across all specs
|
|
31
33
|
const tagTestCounts = {}
|
|
32
34
|
|
|
35
|
+
const jsonResults = {}
|
|
36
|
+
|
|
33
37
|
specs.forEach((filename) => {
|
|
38
|
+
jsonResults[filename] = []
|
|
34
39
|
const source = fs.readFileSync(filename, 'utf8')
|
|
35
40
|
const result = getTestNames(source, true)
|
|
36
41
|
// enable if need to debug the parsed test
|
|
@@ -41,18 +46,28 @@ if (args['--names'] || args['--tags']) {
|
|
|
41
46
|
pendingTestsN += result.pendingTestCount
|
|
42
47
|
|
|
43
48
|
if (args['--names']) {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
if (args['--json']) {
|
|
50
|
+
result.structure.forEach((t) => {
|
|
51
|
+
if (t.type === 'test') {
|
|
52
|
+
jsonResults[filename].push(t.name)
|
|
53
|
+
} else if (t.type === 'suite') {
|
|
54
|
+
jsonResults[filename].push(t.name)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
51
57
|
} else {
|
|
52
|
-
|
|
58
|
+
if (result.pendingTestCount) {
|
|
59
|
+
console.log(
|
|
60
|
+
'%s (%s, %d pending)',
|
|
61
|
+
filename,
|
|
62
|
+
testCount,
|
|
63
|
+
result.pendingTestCount,
|
|
64
|
+
)
|
|
65
|
+
} else {
|
|
66
|
+
console.log('%s (%s)', filename, testCount)
|
|
67
|
+
}
|
|
68
|
+
console.log(formatTestList(result.structure))
|
|
69
|
+
console.log('')
|
|
53
70
|
}
|
|
54
|
-
console.log(formatTestList(result.structure))
|
|
55
|
-
console.log('')
|
|
56
71
|
}
|
|
57
72
|
|
|
58
73
|
if (args['--tags']) {
|
|
@@ -68,19 +83,23 @@ if (args['--names'] || args['--tags']) {
|
|
|
68
83
|
})
|
|
69
84
|
|
|
70
85
|
if (args['--names']) {
|
|
71
|
-
if (
|
|
72
|
-
console.log(
|
|
73
|
-
'found %s (%s, %d pending)',
|
|
74
|
-
pluralize('spec', specs.length, true),
|
|
75
|
-
pluralize('test', testsN, true),
|
|
76
|
-
pendingTestsN,
|
|
77
|
-
)
|
|
86
|
+
if (args['--json']) {
|
|
87
|
+
console.log(JSON.stringify(jsonResults, null, 2))
|
|
78
88
|
} else {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
if (pendingTestsN) {
|
|
90
|
+
console.log(
|
|
91
|
+
'found %s (%s, %d pending)',
|
|
92
|
+
pluralize('spec', specs.length, true),
|
|
93
|
+
pluralize('test', testsN, true),
|
|
94
|
+
pendingTestsN,
|
|
95
|
+
)
|
|
96
|
+
} else {
|
|
97
|
+
console.log(
|
|
98
|
+
'found %s (%s)',
|
|
99
|
+
pluralize('spec', specs.length, true),
|
|
100
|
+
pluralize('test', testsN, true),
|
|
101
|
+
)
|
|
102
|
+
}
|
|
84
103
|
}
|
|
85
104
|
console.log('')
|
|
86
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cypress-specs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Find Cypress spec files using the config settings",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"files": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"ava": "^4.0.0",
|
|
37
37
|
"cypress": "^9.2.0",
|
|
38
|
+
"execa-wrap": "^1.4.0",
|
|
38
39
|
"prettier": "^2.5.1",
|
|
39
40
|
"semantic-release": "^18.0.1"
|
|
40
41
|
},
|