@bahmutov/cy-grep 1.6.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @bahmutov/cy-grep ![cypress version](https://img.shields.io/badge/cypress-12.7.0-brightgreen)
1
+ # @bahmutov/cy-grep ![cypress version](https://img.shields.io/badge/cypress-12.8.1-brightgreen)
2
2
 
3
3
  > Filter tests using substring or tag
4
4
 
@@ -70,6 +70,7 @@ Watch the video [intro to cypress-grep plugin](https://www.youtube.com/watch?v=H
70
70
  - [Debugging in the browser](#debugging-in-the-browser)
71
71
  - [Examples](#examples)
72
72
  - [See also](#see-also)
73
+ - [cy-grep vs cypress-grep vs @cypress/grep](#cy-grep-vs-cypress-grep-vs-cypressgrep)
73
74
  - [Small Print](#small-print)
74
75
 
75
76
  <!-- /MarkdownTOC -->
@@ -288,6 +289,13 @@ If you can pass commas in the environment variable `grepTags`, you can use `,` t
288
289
  CYPRESS_grepTags=one,two npx cypress run
289
290
  ```
290
291
 
292
+ If a specific tag is not found in the specs, you will get a warning in the terminal:
293
+
294
+ ```
295
+ $ npx cypress run --env grepTags=@wrong-tag
296
+ cy-grep: could not find the tag "@wrong-tag" in any of the specs
297
+ ```
298
+
291
299
  ### Tags in the test config object
292
300
 
293
301
  Cypress tests can have their own [test config object](https://on.cypress.io/configuration#Test-Configuration), and when using this plugin you can put the test tags there, either as a single tag string or as an array of tags.
@@ -643,8 +651,25 @@ To see how to debug this plugin, watch the video [Debug cypress-grep Plugin](htt
643
651
  - [cypress-select-tests](https://github.com/bahmutov/cypress-select-tests)
644
652
  - [cypress-skip-test](https://github.com/cypress-io/cypress-skip-test)
645
653
 
654
+ ## cy-grep vs cypress-grep vs @cypress/grep
655
+
656
+ Many years ago I wrote a plugin `cypress-grep`. When I left the company Cypress, I transferred that MIT-licensed plugin to the Cypress GitHub organization. They moved it to the Cypress monorepo and renamed the NPM module `@cypress/grep`. I still use this grep plugin in some projects. When Cypress v10 was released, it broke some of the things in the plugin. Since I needed to fix it quickly and the monorepo setup is suboptimal, I forked the plugin back to my own repo `bahmutov/cy-grep` (this repo) and released under NPM name `@bahmutov/cy-grep`.
657
+
658
+ I plan to maintain the plugin `@bahmutov/cy-grep` in the future, since I rely on it myself **a lot**.
659
+
646
660
  ## Small Print
647
661
 
662
+ Author: Gleb Bahmutov &lt;gleb.bahmutov@gmail.com&gt; &copy; 2022
663
+
664
+ - [@bahmutov](https://twitter.com/bahmutov)
665
+ - [glebbahmutov.com](https://glebbahmutov.com)
666
+ - [blog](https://glebbahmutov.com/blog)
667
+ - [videos](https://www.youtube.com/glebbahmutov)
668
+ - [presentations](https://slides.com/bahmutov)
669
+ - [cypress.tips](https://cypress.tips)
670
+ - [Cypress Tips & Tricks Newsletter](https://cypresstips.substack.com/)
671
+ - [my Cypress courses](https://cypress.tips/courses)
672
+
648
673
  License: MIT - do anything with the code, but don't blame me if it does not work.
649
674
 
650
675
  Support: if you find any problems with this module, email / tweet /
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmutov/cy-grep",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Filter Cypress tests using title or tags",
5
5
  "main": "src/support.js",
6
6
  "scripts": {
@@ -14,11 +14,11 @@
14
14
  "cypress-plugin-config": "^1.2.0",
15
15
  "debug": "^4.3.2",
16
16
  "find-cypress-specs": "^1.29.4",
17
- "find-test-names": "1.28.1",
17
+ "find-test-names": "1.28.3",
18
18
  "globby": "^11.0.4"
19
19
  },
20
20
  "devDependencies": {
21
- "cypress": "12.7.0",
21
+ "cypress": "12.8.1",
22
22
  "cypress-each": "^1.11.0",
23
23
  "cypress-expect": "^3.1.0",
24
24
  "prettier": "^2.8.1",
package/src/utils.js CHANGED
@@ -37,13 +37,20 @@ function parseFullTitleGrep(s) {
37
37
 
38
38
  /**
39
39
  * Parses tags to grep for.
40
- * @param {string} s Tags string like "@tag1+@tag2"
40
+ * @param {string|string[]} s Tags string like "@tag1+@tag2", or array of tags
41
+ * @example
42
+ * parseTagsGrep('@tag1+@tag2')
43
+ * @example
44
+ * parseTagsGrep(['@tag1', '@tag2'])
41
45
  */
42
46
  function parseTagsGrep(s) {
43
47
  if (!s) {
44
48
  return []
45
49
  }
46
50
 
51
+ if (Array.isArray(s)) {
52
+ s = s.join(',')
53
+ }
47
54
  const explicitNotTags = []
48
55
 
49
56
  // top level split - using space or comma, each part is OR