find-cypress-specs 1.23.0 → 1.25.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 +35 -1
- package/bin/find.js +29 -6
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# find-cypress-specs [![renovate-app badge][renovate-badge]][renovate-app]  [](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml)
|
|
2
2
|
|
|
3
3
|
> Find Cypress spec files using the config settings
|
|
4
4
|
|
|
@@ -72,6 +72,8 @@ $ npx find-cypress-specs --branch main --parent --trace-imports cypress --cache-
|
|
|
72
72
|
|
|
73
73
|
The cached trace will be saved in file `deps.json`, you probably want to Git ignore it.
|
|
74
74
|
|
|
75
|
+
You can limit the number of added traced files using the `--max-added-traced-specs <N>` parameter. This avoids ALL specs added when you change some common utility that many specs import.
|
|
76
|
+
|
|
75
77
|
### number of changed files
|
|
76
78
|
|
|
77
79
|
You can print just the number of changed specs
|
|
@@ -165,6 +167,24 @@ cypress/e2e/featureA/user.cy.ts (1 test, 1 pending)
|
|
|
165
167
|
found 1 spec (1 test, 1 pending)
|
|
166
168
|
```
|
|
167
169
|
|
|
170
|
+
## Print skipped tests
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
$ npx find-cypress-specs --names --skipped
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Prints each spec that has skipped tests.
|
|
177
|
+
|
|
178
|
+
## Count skipped tests
|
|
179
|
+
|
|
180
|
+
Prints the single number with the count of skipped tests
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
$ npx find-cypress-specs --names --skipped --count
|
|
184
|
+
|
|
185
|
+
5
|
|
186
|
+
```
|
|
187
|
+
|
|
168
188
|
## cypress.config.ts
|
|
169
189
|
|
|
170
190
|
If the project uses TypeScript and `cypress.config.ts` then this module uses [ts-node/register](https://github.com/TypeStrong/ts-node) to load the config and fetch the spec pattern.
|
|
@@ -210,8 +230,22 @@ Run the utility with environment variable `DEBUG=find-cypress-specs` to see the
|
|
|
210
230
|
|
|
211
231
|
## Examples
|
|
212
232
|
|
|
233
|
+
- 📝 blog post [Run Changed Traced Specs On GitHub Actions](https://glebbahmutov.com/blog/trace-changed-specs/)
|
|
213
234
|
- [chat.io](https://github.com/bahmutov/chat.io) as described in the blog post [Get Faster Feedback From Your Cypress Tests Running On CircleCI](https://glebbahmutov.com/blog/faster-ci-feedback-on-circleci/)
|
|
214
235
|
|
|
236
|
+
## NPM module
|
|
237
|
+
|
|
238
|
+
You can use this module via its NPM module API.
|
|
239
|
+
|
|
240
|
+
```js
|
|
241
|
+
const { getSpecs } = require('find-cypress-specs')
|
|
242
|
+
// somewhere in the cypress.config.js
|
|
243
|
+
setupNodeEvents(on, config) {
|
|
244
|
+
const specs = getSpecs(config)
|
|
245
|
+
// specs is a list of filenames
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
215
249
|
## Small print
|
|
216
250
|
|
|
217
251
|
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2022
|
package/bin/find.js
CHANGED
|
@@ -40,6 +40,8 @@ const args = arg({
|
|
|
40
40
|
// save a JSON file with traced dependencies to save time
|
|
41
41
|
'--cache-trace': Boolean,
|
|
42
42
|
'--time-trace': Boolean,
|
|
43
|
+
// do not add more than this number of extra specs after tracing
|
|
44
|
+
'--max-added-traced-specs': Number,
|
|
43
45
|
// aliases
|
|
44
46
|
'-n': '--names',
|
|
45
47
|
'--name': '--names',
|
|
@@ -112,13 +114,22 @@ if (args['--names'] || args['--tags']) {
|
|
|
112
114
|
addCounts(jsonResults)
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
if (args['--
|
|
116
|
-
|
|
117
|
+
if (args['--count']) {
|
|
118
|
+
let n = 0
|
|
119
|
+
Object.keys(jsonResults).forEach((filename) => {
|
|
120
|
+
const skippedCount = jsonResults[filename].counts.pending
|
|
121
|
+
n += skippedCount
|
|
122
|
+
})
|
|
123
|
+
console.log(n)
|
|
117
124
|
} else {
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
if (args['--json']) {
|
|
126
|
+
console.log(JSON.stringify(jsonResults, null, 2))
|
|
127
|
+
} else {
|
|
128
|
+
const str = stringAllInfo(jsonResults)
|
|
129
|
+
console.log(str)
|
|
130
|
+
}
|
|
131
|
+
console.log('')
|
|
120
132
|
}
|
|
121
|
-
console.log('')
|
|
122
133
|
}
|
|
123
134
|
|
|
124
135
|
if (args['--tags']) {
|
|
@@ -172,6 +183,13 @@ if (args['--names'] || args['--tags']) {
|
|
|
172
183
|
}
|
|
173
184
|
debug('traced dependencies via imports and require')
|
|
174
185
|
debug(deps)
|
|
186
|
+
|
|
187
|
+
// add a sensible limit to the number of extra specs to add
|
|
188
|
+
// when we trace the dependencies in the changed source files
|
|
189
|
+
const addedTracedFiles = []
|
|
190
|
+
const maxAddTracedFiles = args['--max-added-traced-specs'] || 1000
|
|
191
|
+
debug('maximum traced files to add %d', maxAddTracedFiles)
|
|
192
|
+
|
|
175
193
|
Object.entries(deps).forEach(([filename, fileDependents]) => {
|
|
176
194
|
const f = path.join(args['--trace-imports'], filename)
|
|
177
195
|
if (changedFiles.includes(f)) {
|
|
@@ -183,12 +201,17 @@ if (args['--names'] || args['--tags']) {
|
|
|
183
201
|
fileDependents.forEach((name) => {
|
|
184
202
|
const nameInCypressFolder = path.join(args['--trace-imports'], name)
|
|
185
203
|
if (!changedFiles.includes(nameInCypressFolder)) {
|
|
186
|
-
|
|
204
|
+
if (addedTracedFiles.length < maxAddTracedFiles) {
|
|
205
|
+
changedFiles.push(nameInCypressFolder)
|
|
206
|
+
addedTracedFiles.push(nameInCypressFolder)
|
|
207
|
+
}
|
|
187
208
|
}
|
|
188
209
|
})
|
|
189
210
|
}
|
|
190
211
|
})
|
|
212
|
+
debug('added %d traced specs %o', addedTracedFiles.length, addedTracedFiles)
|
|
191
213
|
}
|
|
214
|
+
|
|
192
215
|
let changedSpecs = specs.filter((file) => changedFiles.includes(file))
|
|
193
216
|
debug('changed %d specs %o', changedSpecs.length, changedSpecs)
|
|
194
217
|
if (args['--set-gha-outputs']) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cypress-specs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"description": "Find Cypress spec files using the config settings",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"files": [
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"demo": "DEBUG=find-cypress-specs node ./bin/find",
|
|
17
17
|
"demo-names": "node ./bin/find --names",
|
|
18
18
|
"demo-skipped-tests": "node ./bin/find --names --skipped",
|
|
19
|
+
"demo-count-skipped-tests": "node ./bin/find --names --skipped --count",
|
|
19
20
|
"demo-tags": "node ./bin/find --tags",
|
|
20
21
|
"demo-tags-json": "node ./bin/find --tags --json",
|
|
21
22
|
"demo-names-and-tags": "node ./bin/find --names --tags",
|
|
@@ -43,11 +44,11 @@
|
|
|
43
44
|
"homepage": "https://github.com/bahmutov/find-cypress-specs#readme",
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"ava": "^4.0.0",
|
|
46
|
-
"cypress": "12.
|
|
47
|
+
"cypress": "12.3.0",
|
|
47
48
|
"execa-wrap": "^1.4.0",
|
|
48
49
|
"prettier": "^2.5.1",
|
|
49
50
|
"really-need": "^1.9.2",
|
|
50
|
-
"semantic-release": "
|
|
51
|
+
"semantic-release": "20.0.2",
|
|
51
52
|
"sinon": "^13.0.1",
|
|
52
53
|
"typescript": "^4.6.3"
|
|
53
54
|
},
|