find-cypress-specs 1.0.1 → 1.0.2

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
@@ -12,7 +12,7 @@ cypress/e2e/spec.js,cypress/e2e/featureA/user.js
12
12
 
13
13
  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.
14
14
 
15
- You can see how Cypress finds the specs using `DEBUG=cypress:cli,cypress:server:specs` environment variable to see verbose logs.
15
+ You can see how Cypress finds the specs using `DEBUG=cypress:cli,cypress:server:specs` environment variable to see verbose logs. The logic should be in the file `packages/server/lib/util/specs.ts` in the repo [cypress-io/cypress](https://github.com/cypress-io/cypress)
16
16
 
17
17
  ## Debugging
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-cypress-specs",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Find Cypress spec files using the config settings",
5
5
  "main": "src",
6
6
  "files": [
@@ -37,6 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "debug": "^4.3.3",
40
- "globby": "^11.0.4"
40
+ "globby": "^11.0.4",
41
+ "minimatch": "^3.0.4"
41
42
  }
42
43
  }
package/src/index.js CHANGED
@@ -2,6 +2,9 @@ const debug = require('debug')('find-cypress-specs')
2
2
  const fs = require('fs')
3
3
  const path = require('path')
4
4
  const globby = require('globby')
5
+ const minimatch = require('minimatch')
6
+
7
+ const MINIMATCH_OPTIONS = { dot: true, matchBase: true }
5
8
 
6
9
  /**
7
10
  * Reads the cypress config file and returns the relevant properties
@@ -32,13 +35,32 @@ function findCypressSpecs(opts = {}) {
32
35
  debug('options %o', options)
33
36
 
34
37
  const files = globby.sync(options.testFiles, {
38
+ sort: true,
35
39
  cwd: options.integrationFolder,
36
40
  ignore: options.ignoreTestFiles,
37
41
  })
38
42
  debug('found %d file(s) %o', files.length, files)
39
43
 
44
+ // go through the files again and eliminate files that match
45
+ // the ignore patterns
46
+
47
+ // a function which returns true if the file does NOT match
48
+ // all of our ignored patterns
49
+ const doesNotMatchAllIgnoredPatterns = (file) => {
50
+ // using {dot: true} here so that folders with a '.' in them are matched
51
+ // as regular characters without needing an '.' in the
52
+ // using {matchBase: true} here so that patterns without a globstar **
53
+ // match against the basename of the file
54
+ return options.ignoreTestFiles.every((pattern) => {
55
+ return !minimatch(file, pattern, MINIMATCH_OPTIONS)
56
+ })
57
+ }
58
+
59
+ const filtered = files.filter(doesNotMatchAllIgnoredPatterns)
60
+ debug('filtered specs %o', filtered)
61
+
40
62
  // return spec files with the added integration folder prefix
41
- return files.map((file) => path.join(options.integrationFolder, file))
63
+ return filtered.map((file) => path.join(options.integrationFolder, file))
42
64
  }
43
65
 
44
66
  function getSpecs() {