@bahmutov/cy-grep 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmutov/cy-grep",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "Filter Cypress tests using title or tags",
5
5
  "main": "src/support.js",
6
6
  "scripts": {
@@ -8,7 +8,8 @@
8
8
  "cy:open": "cypress open --e2e -b electron --config specPattern='**/unit.js'",
9
9
  "badges": "npx -p dependency-version-badge update-badge cypress",
10
10
  "semantic-release": "semantic-release",
11
- "deps": "npm audit --report --omit dev"
11
+ "deps": "npm audit --report --omit dev",
12
+ "stop-only": "stop-only --folder cypress/e2e"
12
13
  },
13
14
  "dependencies": {
14
15
  "cypress-plugin-config": "^1.2.0",
@@ -23,6 +24,7 @@
23
24
  "cypress-expect": "^3.1.0",
24
25
  "prettier": "^2.8.1",
25
26
  "semantic-release": "^20.1.3",
27
+ "stop-only": "^3.3.1",
26
28
  "typescript": "^4.7.4"
27
29
  },
28
30
  "peerDependencies": {
package/src/plugin.js CHANGED
@@ -114,7 +114,7 @@ function cypressGrepPlugin(config) {
114
114
  } else if (grepTags) {
115
115
  const parsedGrep = parseGrep(null, grepTags, grepPrefixAt)
116
116
  debug('parsed grep tags %o', parsedGrep)
117
- const mentionedTags = getMentionedTags(grepTags)
117
+ const mentionedTags = getMentionedTags(grepTags, grepPrefixAt)
118
118
  debug('user mentioned tags %o', mentionedTags)
119
119
  // unique tags found across all specs we search
120
120
  const foundTags = new Set()
package/src/utils.js CHANGED
@@ -118,9 +118,11 @@ function parseTagsGrep(s, grepPrefixAt = false) {
118
118
  * Given a user string of tags to find, with various connectors,
119
119
  * returns the list of just the tags themselves. Could be used to
120
120
  * quickly filter test specs or find misspelled tags.
121
+ * @param {string} s String of tags passed by the user
122
+ * @param {boolean} grepPrefixAt Enforce the `@` character at the start of each tag
121
123
  * @returns {string[]} list of unique tags
122
124
  */
123
- function getMentionedTags(s) {
125
+ function getMentionedTags(s, grepPrefixAt = false) {
124
126
  if (!s) {
125
127
  return []
126
128
  }
@@ -132,6 +134,15 @@ function getMentionedTags(s) {
132
134
  // remove any "-" at the start of the tag
133
135
  // because these are to signal inverted tags
134
136
  .map((s) => (s.startsWith('-') ? s.slice(1) : s))
137
+ .map((tag) => {
138
+ if (grepPrefixAt) {
139
+ if (!tag.startsWith('@')) {
140
+ return '@' + tag
141
+ }
142
+ }
143
+
144
+ return tag
145
+ })
135
146
  const uniqueTags = [...new Set(tags)]
136
147
  return uniqueTags.sort()
137
148
  }