cypress-plugin-grep-boxes 2.0.1 → 2.2.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.
Files changed (3) hide show
  1. package/README.md +25 -1
  2. package/index.js +32 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,7 +18,9 @@ A companion Cypress plugin for <code>cy-grep</code> that allows user to run spec
18
18
  - [Installation](#-installation)
19
19
  - [Setup](#-setup)
20
20
  - [Open mode](#-open-mode)
21
+ - [Using cypress-plugin-filter-runnables](#using-cypress-plugin-filter-runnables)
21
22
  - [Use Required Test Tags Instead Of Skipping Tests](#use-required-test-tags-instead-of-skipping-tests)
23
+ - [hideSpecTags](#hideSpecTags)
22
24
  - [disableInitialAutoRun](#disableInitialAutoRun)
23
25
  - [Contributions](#contributions)
24
26
 
@@ -75,6 +77,11 @@ Within each spec in Cypress `open` mode:
75
77
 
76
78
  <img width="295" height="182" alt="grep-boxes-ui" src="https://github.com/user-attachments/assets/fad9ebc9-e417-41aa-9f31-519855113d17" />
77
79
 
80
+ ### Using cypress-plugin-filter-runnables
81
+
82
+ **NEW** in v2.1.0: If filtering tests using [cypress-plugin-filter-runnables](https://github.com/dennisbergevin/cypress-plugin-filter-runnables), simply click the filter toggle located on the reporter above to only run those tests.
83
+
84
+ No need to check each checkbox of each test you see after filtering by test title!
78
85
 
79
86
  ### Use Required Test Tags Instead Of Skipping Tests
80
87
 
@@ -99,6 +106,24 @@ To run just those tests with the required tag `@skip` in interactive mode:
99
106
  npx cypress open --env grepTags=@skip
100
107
  ```
101
108
 
109
+ ## hideSpecTags
110
+
111
+ The `cypress-plugin-grep-boxes` plugin (new in v2.0.0) displays all available `effectiveTestTags` in the Cypress Test Runner for each test.
112
+
113
+ If for any reason you'd like to exclude specific tags from being added to the Cypress Test Runner, use the environment variable `hideSpecTags` set to an array of tags you do not want to be displayed in the Cypress Test Runner.
114
+
115
+ Example:
116
+
117
+ ```json
118
+ {
119
+ "env": {
120
+ "hideSpecTags": ["@smoke", "@sanity"]
121
+ }
122
+ }
123
+ ```
124
+
125
+ The example above would not add any tags to Cypress Test Runner titled `@smoke` and `@sanity`.
126
+
102
127
  ## disableInitialAutoRun
103
128
 
104
129
  Cypress Test Runner UI automatically runs available tests once a spec file is open.
@@ -107,7 +132,6 @@ To prevent this behavior to have control of when and which tests to run, add the
107
132
 
108
133
  ![disableInitialAutoRun_demo](https://github.com/user-attachments/assets/95fc4807-847b-432e-9b03-dc4fbe9f955a)
109
134
 
110
-
111
135
  ```bash
112
136
  # Example via CLI
113
137
  npx cypress open --env disableInitialAutoRun=true
package/index.js CHANGED
@@ -177,12 +177,37 @@ grepTestToggleElement?.addEventListener('change', (e) => {
177
177
  });
178
178
  });
179
179
 
180
+ // run all tests displayed in the spec if none are checked
181
+ // this enables cohesion with this plugin and cypress-plugin-filter-runnables
182
+ // the display: none is used to hide runnables not matching a filter
183
+ if (tests.length === 0) {
184
+ const checkboxes = [
185
+ ...window.top?.document.querySelectorAll('.grep-test-checkbox'),
186
+ ].filter((box) => {
187
+ const runnable = box.closest('.runnable');
188
+ return runnable && window.getComputedStyle(runnable).display !== 'none';
189
+ });
190
+
191
+ checkboxes.forEach((box) => tests.push(box.value));
192
+ }
193
+
180
194
  Cypress.grep(tests.join(';'));
181
195
 
182
196
  // when checked, grep only selected tests in spec
183
197
  grepTestToggleLabelElement.innerHTML = turnOngrepTestToggleIcon;
184
198
  grepTestToggleTooltipElement.innerHTML = turnOngrepTestToggleDescription;
185
199
  } else {
200
+ // for cypress-plugin-filter-runnables to clear search when grepTestToggle is unchecked
201
+ const searchInput = window.top?.document.querySelector(
202
+ '#test-suite-filter-search'
203
+ );
204
+ const clearBtn = window.top?.document.querySelector(
205
+ '#clear-test-suite-filter-search'
206
+ );
207
+ if (searchInput != '') {
208
+ clearBtn?.click();
209
+ }
210
+
186
211
  if (stopBtn) {
187
212
  stopBtn.click();
188
213
  }
@@ -381,7 +406,13 @@ function getTagsForTitle(title, fullTagsObj) {
381
406
  return []; // Title not found
382
407
  }
383
408
 
384
- return [...test.effectiveTestTags, ...test.requiredTestTags];
409
+ const allTags = [...test.effectiveTestTags, ...test.requiredTestTags];
410
+ const tagsToExclude = Cypress.env('hideSpecTags');
411
+
412
+ if (!tagsToExclude?.length) return allTags;
413
+
414
+ // Filter out excluded tags
415
+ return allTags.filter((tag) => !tagsToExclude?.includes(tag));
385
416
  }
386
417
 
387
418
  function renderTagPills(tags, container) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress-plugin-grep-boxes",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "Cypress plugin that allows user to run specific tests in open mode.",
5
5
  "main": "./index.js",
6
6
  "keywords": [