find-cypress-specs 1.0.3 → 1.2.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 +21 -0
- package/bin/find.js +32 -1
- package/package.json +6 -2
- package/src/index.js +2 -1
package/README.md
CHANGED
|
@@ -8,6 +8,27 @@ $ npx find-cypress-specs
|
|
|
8
8
|
cypress/e2e/spec.js,cypress/e2e/featureA/user.js
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Test names
|
|
12
|
+
|
|
13
|
+
You can print each spec file with the suite and test names inside of it (found using [find-test-names](https://github.com/bahmutov/find-test-names))
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
$ npx find-cypress-specs --names
|
|
17
|
+
# prints something like
|
|
18
|
+
|
|
19
|
+
cypress/e2e/spec.js
|
|
20
|
+
└─ parent suite [@main]
|
|
21
|
+
├─ works
|
|
22
|
+
└─ inner suite
|
|
23
|
+
└─ shows something [@user]
|
|
24
|
+
|
|
25
|
+
cypress/e2e/featureA/user.js
|
|
26
|
+
├─ works
|
|
27
|
+
└⊙ needs to be written
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
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
|
+
|
|
11
32
|
## Details
|
|
12
33
|
|
|
13
34
|
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
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
const arg = require('arg')
|
|
3
4
|
const { getSpecs } = require('../src')
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const pluralize = require('pluralize')
|
|
7
|
+
const { getTestNames, formatTestList } = require('find-test-names')
|
|
8
|
+
|
|
9
|
+
const args = arg({
|
|
10
|
+
'--names': Boolean,
|
|
11
|
+
|
|
12
|
+
// aliases
|
|
13
|
+
'-n': '--names',
|
|
14
|
+
})
|
|
4
15
|
|
|
5
16
|
const specs = getSpecs()
|
|
6
|
-
|
|
17
|
+
if (args['--names']) {
|
|
18
|
+
if (!specs.length) {
|
|
19
|
+
console.log('no specs found')
|
|
20
|
+
} else {
|
|
21
|
+
console.log('')
|
|
22
|
+
specs.forEach((filename) => {
|
|
23
|
+
const source = fs.readFileSync(filename, 'utf8')
|
|
24
|
+
const result = getTestNames(source, true)
|
|
25
|
+
// enable if need to debug the parsed test
|
|
26
|
+
// console.dir(result.structure, { depth: null })
|
|
27
|
+
|
|
28
|
+
const testCount = pluralize('test', result.testNames.length, true)
|
|
29
|
+
|
|
30
|
+
console.log('%s (%s)', filename, testCount)
|
|
31
|
+
console.log(formatTestList(result.structure))
|
|
32
|
+
console.log('')
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
console.log(specs.join(','))
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cypress-specs",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Find Cypress spec files using the config settings",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"files": [
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"test": "ava",
|
|
15
15
|
"cy:run": "DEBUG=cypress:cli,cypress:server:specs cypress run",
|
|
16
16
|
"demo": "DEBUG=find-cypress-specs node ./bin/find",
|
|
17
|
+
"demo-names": "node ./bin/find --names",
|
|
17
18
|
"semantic-release": "semantic-release"
|
|
18
19
|
},
|
|
19
20
|
"repository": {
|
|
@@ -36,8 +37,11 @@
|
|
|
36
37
|
"semantic-release": "^18.0.1"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
40
|
+
"arg": "^5.0.1",
|
|
39
41
|
"debug": "^4.3.3",
|
|
42
|
+
"find-test-names": "^1.9.3",
|
|
40
43
|
"globby": "^11.0.4",
|
|
41
|
-
"minimatch": "^3.0.4"
|
|
44
|
+
"minimatch": "^3.0.4",
|
|
45
|
+
"pluralize": "^8.0.0"
|
|
42
46
|
}
|
|
43
47
|
}
|
package/src/index.js
CHANGED
|
@@ -59,7 +59,8 @@ function findCypressSpecs(opts = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const filtered = files.filter(doesNotMatchAllIgnoredPatterns)
|
|
62
|
-
debug('filtered specs
|
|
62
|
+
debug('filtered %d specs', filtered.length)
|
|
63
|
+
debug(filtered.join('\n'))
|
|
63
64
|
|
|
64
65
|
// return spec files with the added integration folder prefix
|
|
65
66
|
return filtered.map((file) => path.join(options.integrationFolder, file))
|