find-cypress-specs 1.18.0 → 1.19.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 CHANGED
@@ -1,4 +1,4 @@
1
- # find-cypress-specs [![renovate-app badge][renovate-badge]][renovate-app] ![cypress version](https://img.shields.io/badge/cypress-10.3.0-brightgreen) [![ci](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml)
1
+ # find-cypress-specs [![renovate-app badge][renovate-badge]][renovate-app] ![cypress version](https://img.shields.io/badge/cypress-10.8.0-brightgreen) [![ci](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml/badge.svg?branch=main)](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
 
@@ -115,6 +115,12 @@ $ npx find-cypress-specs --names --tagged <tag1>,<tag2>,<tag3>,...
115
115
  # tagged with tag1 or tag2 or tag3 or ...
116
116
  ```
117
117
 
118
+ ## cypress.config.ts
119
+
120
+ 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.
121
+
122
+ **Tip:** read my blog post [Convert Cypress Specs from JavaScript to TypeScript](https://glebbahmutov.com/blog/cypress-js-to-ts/).
123
+
118
124
  ## Details
119
125
 
120
126
  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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-cypress-specs",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Find Cypress spec files using the config settings",
5
5
  "main": "src",
6
6
  "files": [
@@ -40,11 +40,11 @@
40
40
  "homepage": "https://github.com/bahmutov/find-cypress-specs#readme",
41
41
  "devDependencies": {
42
42
  "ava": "^4.0.0",
43
- "cypress": "10.3.0",
43
+ "cypress": "10.8.0",
44
44
  "execa-wrap": "^1.4.0",
45
45
  "prettier": "^2.5.1",
46
46
  "really-need": "^1.9.2",
47
- "semantic-release": "19.0.3",
47
+ "semantic-release": "19.0.5",
48
48
  "sinon": "^13.0.1",
49
49
  "typescript": "^4.6.3"
50
50
  },
@@ -57,6 +57,7 @@
57
57
  "minimatch": "^3.0.4",
58
58
  "pluralize": "^8.0.0",
59
59
  "require-and-forget": "^1.0.0",
60
- "shelljs": "^0.8.5"
60
+ "shelljs": "^0.8.5",
61
+ "ts-node": "^10.9.1"
61
62
  }
62
63
  }
package/src/index.js CHANGED
@@ -31,11 +31,31 @@ function getConfigJs(filename) {
31
31
  return definedConfig
32
32
  }
33
33
 
34
- function getConfig(filename = './cypress.config.js') {
35
- if (filename.endsWith('.json')) {
36
- return getConfigJson(filename)
34
+ function getConfigTs(filename) {
35
+ require('ts-node/register')
36
+ const jsFile = path.join(process.cwd(), filename)
37
+ debug('loading Cypress config from %s', jsFile)
38
+ const definedConfig = requireEveryTime(jsFile)
39
+ return definedConfig
40
+ }
41
+
42
+ function getConfig() {
43
+ if (fs.existsSync('./cypress.config.js')) {
44
+ debug('found file cypress.config.js')
45
+ return getConfigJs('./cypress.config.js')
37
46
  }
38
- return getConfigJs(filename)
47
+
48
+ if (fs.existsSync('./cypress.config.ts')) {
49
+ debug('found file cypress.config.ts')
50
+ return getConfigTs('./cypress.config.ts')
51
+ }
52
+
53
+ if (fs.existsSync('./cypress.json')) {
54
+ debug('found file cypress.json')
55
+ return getConfigJson('./cypress.config.js')
56
+ }
57
+
58
+ throw new Error('Do not know how to find and load Cypress config file')
39
59
  }
40
60
 
41
61
  function findCypressSpecsV9(opts = {}) {