find-cypress-specs 1.13.0 → 1.14.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
@@ -1,4 +1,4 @@
1
- # find-cypress-specs [![renovate-app badge][renovate-badge]][renovate-app] ![cypress version](https://img.shields.io/badge/cypress-9.5.1-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-9.5.2-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
 
@@ -77,6 +77,14 @@ $ npx find-cypress-specs --names --tagged <single tag>
77
77
  # finds all specs and tests, then filters the output by a single tag
78
78
  ```
79
79
 
80
+ ## Test names filtered by multiple tags
81
+
82
+ ```bash
83
+ $ npx find-cypress-specs --names --tagged <tag1>,<tag2>,<tag3>,...
84
+ # finds all specs and tests, then filters the output showing all tests
85
+ # tagged with tag1 or tag2 or tag3 or ...
86
+ ```
87
+
80
88
  ## Details
81
89
 
82
90
  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
@@ -7,8 +7,7 @@ const { addCounts } = require('../src/count')
7
7
  const { stringAllInfo } = require('../src/print')
8
8
 
9
9
  const fs = require('fs')
10
- const pluralize = require('pluralize')
11
- const { getTestNames, formatTestList, countTags } = require('find-test-names')
10
+ const { getTestNames, countTags } = require('find-test-names')
12
11
  const consoleTable = require('console.table')
13
12
  const debug = require('debug')('find-cypress-specs')
14
13
 
@@ -74,9 +73,13 @@ if (args['--names'] || args['--tags']) {
74
73
 
75
74
  if (args['--names']) {
76
75
  if (args['--tagged']) {
77
- // filter all collected tests to those that have the given tag
78
- debug('filtering all tests by tag "%s"', args['--tagged'])
79
- pickTaggedTestsFrom(jsonResults, args['--tagged'])
76
+ // filter all collected tests to those that have the given tag(s)
77
+ const splitTags = args['--tagged']
78
+ .split(',')
79
+ .map((s) => s.trim())
80
+ .filter(Boolean)
81
+ debug('filtering all tests by tag "%o"', splitTags)
82
+ pickTaggedTestsFrom(jsonResults, splitTags)
80
83
  // recompute the number of tests
81
84
  addCounts(jsonResults)
82
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-cypress-specs",
3
- "version": "1.13.0",
3
+ "version": "1.14.2",
4
4
  "description": "Find Cypress spec files using the config settings",
5
5
  "main": "src",
6
6
  "files": [
@@ -40,7 +40,7 @@
40
40
  "homepage": "https://github.com/bahmutov/find-cypress-specs#readme",
41
41
  "devDependencies": {
42
42
  "ava": "^4.0.0",
43
- "cypress": "9.5.1",
43
+ "cypress": "9.5.2",
44
44
  "execa-wrap": "^1.4.0",
45
45
  "prettier": "^2.5.1",
46
46
  "semantic-release": "19.0.2"
@@ -49,7 +49,7 @@
49
49
  "arg": "^5.0.1",
50
50
  "console.table": "^0.10.0",
51
51
  "debug": "^4.3.3",
52
- "find-test-names": "^1.14.1",
52
+ "find-test-names": "^1.15.1",
53
53
  "globby": "^11.0.4",
54
54
  "minimatch": "^3.0.4",
55
55
  "pluralize": "^8.0.0",
package/src/tagged.js CHANGED
@@ -1,22 +1,35 @@
1
1
  const { addCounts } = require('./count')
2
2
 
3
+ function arraysOverlap(a, b) {
4
+ if (!Array.isArray(a) || !Array.isArray(b)) {
5
+ return false
6
+ }
7
+
8
+ if (a.length < b.length) {
9
+ return a.some((item) => b.includes(item))
10
+ } else {
11
+ return b.some((item) => a.includes(item))
12
+ }
13
+ }
14
+
3
15
  // note: modifies the tests in place
4
16
  function pickTaggedTests(tests, tag) {
5
17
  if (!Array.isArray(tests)) {
6
18
  return false
7
19
  }
20
+ const tags = Array.isArray(tag) ? tag : [tag]
8
21
  const filteredTests = tests.filter((test) => {
9
22
  if (test.type === 'test') {
10
- return test.tags && test.tags.includes(tag)
23
+ return test.tags && arraysOverlap(test.tags, tags)
11
24
  } else if (test.type === 'suite') {
12
- if (test.tags && test.tags.includes(tag)) {
25
+ if (test.tags && arraysOverlap(test.tags, tags)) {
13
26
  return true
14
27
  }
15
28
 
16
29
  // maybe there is some test inside this suite
17
30
  // with the tag? Filter all other tests
18
31
  return (
19
- pickTaggedTests(test.tests, tag) || pickTaggedTests(test.suites, tag)
32
+ pickTaggedTests(test.tests, tags) || pickTaggedTests(test.suites, tags)
20
33
  )
21
34
  }
22
35
  })
@@ -51,4 +64,9 @@ function pickTaggedTestsFrom(json, tag) {
51
64
  return result
52
65
  }
53
66
 
54
- module.exports = { pickTaggedTestsFrom, removeEmptyNodes, pickTaggedTests }
67
+ module.exports = {
68
+ arraysOverlap,
69
+ pickTaggedTestsFrom,
70
+ removeEmptyNodes,
71
+ pickTaggedTests,
72
+ }