find-cypress-specs 1.0.2 → 1.1.1
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 +28 -1
- package/package.json +4 -1
- package/src/index.js +5 -2
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,33 @@
|
|
|
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 { getTestNames, formatTestList } = require('find-test-names')
|
|
7
|
+
|
|
8
|
+
const args = arg({
|
|
9
|
+
'--names': Boolean,
|
|
10
|
+
|
|
11
|
+
// aliases
|
|
12
|
+
'-n': '--names',
|
|
13
|
+
})
|
|
4
14
|
|
|
5
15
|
const specs = getSpecs()
|
|
6
|
-
|
|
16
|
+
if (args['--names']) {
|
|
17
|
+
if (!specs.length) {
|
|
18
|
+
console.log('no specs found')
|
|
19
|
+
} else {
|
|
20
|
+
console.log('')
|
|
21
|
+
specs.forEach((filename) => {
|
|
22
|
+
const source = fs.readFileSync(filename, 'utf8')
|
|
23
|
+
const result = getTestNames(source, true)
|
|
24
|
+
// enable if need to debug the parsed test
|
|
25
|
+
// console.dir(result.structure, { depth: null })
|
|
26
|
+
console.log(filename)
|
|
27
|
+
console.log(formatTestList(result.structure))
|
|
28
|
+
console.log('')
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
console.log(specs.join(','))
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cypress-specs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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,7 +37,9 @@
|
|
|
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.2",
|
|
40
43
|
"globby": "^11.0.4",
|
|
41
44
|
"minimatch": "^3.0.4"
|
|
42
45
|
}
|
package/src/index.js
CHANGED
|
@@ -43,6 +43,8 @@ function findCypressSpecs(opts = {}) {
|
|
|
43
43
|
|
|
44
44
|
// go through the files again and eliminate files that match
|
|
45
45
|
// the ignore patterns
|
|
46
|
+
const ignorePatterns = [].concat(options.ignoreTestFiles)
|
|
47
|
+
debug('ignore patterns %o', ignorePatterns)
|
|
46
48
|
|
|
47
49
|
// a function which returns true if the file does NOT match
|
|
48
50
|
// all of our ignored patterns
|
|
@@ -51,13 +53,14 @@ function findCypressSpecs(opts = {}) {
|
|
|
51
53
|
// as regular characters without needing an '.' in the
|
|
52
54
|
// using {matchBase: true} here so that patterns without a globstar **
|
|
53
55
|
// match against the basename of the file
|
|
54
|
-
return
|
|
56
|
+
return ignorePatterns.every((pattern) => {
|
|
55
57
|
return !minimatch(file, pattern, MINIMATCH_OPTIONS)
|
|
56
58
|
})
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
const filtered = files.filter(doesNotMatchAllIgnoredPatterns)
|
|
60
|
-
debug('filtered specs
|
|
62
|
+
debug('filtered %d specs', filtered.length)
|
|
63
|
+
debug(filtered.join('\n'))
|
|
61
64
|
|
|
62
65
|
// return spec files with the added integration folder prefix
|
|
63
66
|
return filtered.map((file) => path.join(options.integrationFolder, file))
|