find-cypress-specs 1.0.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 +52 -0
- package/bin/find.js +6 -0
- package/package.json +42 -0
- package/src/index.js +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# find-cypress-specs 
|
|
2
|
+
|
|
3
|
+
> Find Cypress spec files using the config settings
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
You can see how Cypress finds the specs using `DEBUG=cypress:cli,cypress:server:specs` environment variable to see verbose logs.
|
|
8
|
+
|
|
9
|
+
## Debugging
|
|
10
|
+
|
|
11
|
+
Run the utility with environment variable `DEBUG=find-cypress-specs` to see the verbose logs
|
|
12
|
+
|
|
13
|
+
## Small print
|
|
14
|
+
|
|
15
|
+
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2022
|
|
16
|
+
|
|
17
|
+
- [@bahmutov](https://twitter.com/bahmutov)
|
|
18
|
+
- [glebbahmutov.com](https://glebbahmutov.com)
|
|
19
|
+
- [blog](https://glebbahmutov.com/blog)
|
|
20
|
+
- [videos](https://www.youtube.com/glebbahmutov)
|
|
21
|
+
- [presentations](https://slides.com/bahmutov)
|
|
22
|
+
- [cypress.tips](https://cypress.tips)
|
|
23
|
+
|
|
24
|
+
License: MIT - do anything with the code, but don't blame me if it does not work.
|
|
25
|
+
|
|
26
|
+
Support: if you find any problems with this module, email / tweet /
|
|
27
|
+
[open issue](https://github.com/bahmutov/find-cypress-specs/issues) on Github
|
|
28
|
+
|
|
29
|
+
## MIT License
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2022 Gleb Bahmutov <gleb.bahmutov@gmail.com>
|
|
32
|
+
|
|
33
|
+
Permission is hereby granted, free of charge, to any person
|
|
34
|
+
obtaining a copy of this software and associated documentation
|
|
35
|
+
files (the "Software"), to deal in the Software without
|
|
36
|
+
restriction, including without limitation the rights to use,
|
|
37
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
38
|
+
copies of the Software, and to permit persons to whom the
|
|
39
|
+
Software is furnished to do so, subject to the following
|
|
40
|
+
conditions:
|
|
41
|
+
|
|
42
|
+
The above copyright notice and this permission notice shall be
|
|
43
|
+
included in all copies or substantial portions of the Software.
|
|
44
|
+
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
46
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
47
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
48
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
49
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
50
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
51
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
52
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/bin/find.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "find-cypress-specs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Find Cypress spec files using the config settings",
|
|
5
|
+
"main": "src",
|
|
6
|
+
"files": [
|
|
7
|
+
"bin",
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
10
|
+
"bin": {
|
|
11
|
+
"find-cypress-specs": "bin/find.js"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "ava",
|
|
15
|
+
"cy:run": "DEBUG=cypress:cli,cypress:server:specs cypress run",
|
|
16
|
+
"demo": "DEBUG=find-cypress-specs node ./bin/find",
|
|
17
|
+
"semantic-release": "semantic-release"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/bahmutov/find-cypress-specs.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"cypress-plugin"
|
|
25
|
+
],
|
|
26
|
+
"author": "Gleb Bahmutov <gleb.bahmutov@mail.com>",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/bahmutov/find-cypress-specs/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/bahmutov/find-cypress-specs#readme",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"ava": "^4.0.0",
|
|
34
|
+
"cypress": "^9.2.0",
|
|
35
|
+
"prettier": "^2.5.1",
|
|
36
|
+
"semantic-release": "^18.0.1"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"debug": "^4.3.3",
|
|
40
|
+
"globby": "^11.0.4"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const debug = require('debug')('find-cypress-specs')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const globby = require('globby')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads the cypress config file and returns the relevant properties
|
|
8
|
+
*/
|
|
9
|
+
function getConfig(filename = 'cypress.json') {
|
|
10
|
+
const s = fs.readFileSync(filename, 'utf8')
|
|
11
|
+
const config = JSON.parse(s)
|
|
12
|
+
const options = {
|
|
13
|
+
integrationFolder: config.integrationFolder,
|
|
14
|
+
testFiles: config.testFiles,
|
|
15
|
+
ignoreTestFiles: config.ignoreTestFiles,
|
|
16
|
+
}
|
|
17
|
+
debug('got config options %o', options)
|
|
18
|
+
return options
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function findCypressSpecs(opts = {}) {
|
|
22
|
+
const defaults = {
|
|
23
|
+
integrationFolder: 'cypress/integration',
|
|
24
|
+
testFiles: '**/*.js',
|
|
25
|
+
ignoreTestFiles: [],
|
|
26
|
+
}
|
|
27
|
+
const options = {
|
|
28
|
+
...defaults,
|
|
29
|
+
...opts,
|
|
30
|
+
}
|
|
31
|
+
debug('options %o', options)
|
|
32
|
+
|
|
33
|
+
const files = globby.sync(options.testFiles, {
|
|
34
|
+
cwd: options.integrationFolder,
|
|
35
|
+
ignore: options.ignoreTestFiles,
|
|
36
|
+
})
|
|
37
|
+
debug('found %d file(s) %o', files.length, files)
|
|
38
|
+
|
|
39
|
+
// return spec files with the added integration folder prefix
|
|
40
|
+
return files.map((file) => path.join(options.integrationFolder, file))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getSpecs() {
|
|
44
|
+
const options = getConfig()
|
|
45
|
+
const specs = findCypressSpecs(options)
|
|
46
|
+
return specs
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
getSpecs,
|
|
51
|
+
// individual utilities
|
|
52
|
+
getConfig,
|
|
53
|
+
findCypressSpecs,
|
|
54
|
+
}
|