cypress-plugin-grep-boxes 2.0.1 → 2.1.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 +6 -1
  2. package/index.js +25 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,6 +18,7 @@ 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)
22
23
  - [disableInitialAutoRun](#disableInitialAutoRun)
23
24
  - [Contributions](#contributions)
@@ -75,6 +76,11 @@ Within each spec in Cypress `open` mode:
75
76
 
76
77
  <img width="295" height="182" alt="grep-boxes-ui" src="https://github.com/user-attachments/assets/fad9ebc9-e417-41aa-9f31-519855113d17" />
77
78
 
79
+ ### Using cypress-plugin-filter-runnables
80
+
81
+ **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.
82
+
83
+ No need to check each checkbox of each test you see after filtering by test title!
78
84
 
79
85
  ### Use Required Test Tags Instead Of Skipping Tests
80
86
 
@@ -107,7 +113,6 @@ To prevent this behavior to have control of when and which tests to run, add the
107
113
 
108
114
  ![disableInitialAutoRun_demo](https://github.com/user-attachments/assets/95fc4807-847b-432e-9b03-dc4fbe9f955a)
109
115
 
110
-
111
116
  ```bash
112
117
  # Example via CLI
113
118
  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
  }
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.1.0",
4
4
  "description": "Cypress plugin that allows user to run specific tests in open mode.",
5
5
  "main": "./index.js",
6
6
  "keywords": [