webship-js 2.0.4 → 2.0.6

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 (211) hide show
  1. package/.drone.yml +0 -0
  2. package/.harness/webship-js-pipeline.yml +0 -0
  3. package/.semaphore/semaphore.yml +0 -0
  4. package/.teamcity/pom.xml +0 -0
  5. package/.teamcity/settings.kts +0 -0
  6. package/.travis.yml +0 -0
  7. package/AGENTS.md +50 -14
  8. package/CLAUDE.md +326 -104
  9. package/Jenkinsfile +0 -0
  10. package/azure-pipelines.yml +0 -0
  11. package/bamboo-specs/bamboo.yml +0 -0
  12. package/bin/init-webship.js +1 -14
  13. package/bin/postinstall.js +0 -0
  14. package/buildspec.yml +0 -0
  15. package/cloudbuild.yaml +0 -0
  16. package/codefresh.yml +0 -0
  17. package/cucumber.js +3 -13
  18. package/docs/00-quick-start.md +0 -0
  19. package/docs/01-getting-started.md +0 -0
  20. package/docs/02-bbr-smart-waits.md +24 -1
  21. package/docs/03-selector-registry.md +0 -0
  22. package/docs/04-step-reference.md +4 -0
  23. package/docs/05-web-first-assertions.md +0 -0
  24. package/docs/06-network-and-dialogs.md +0 -0
  25. package/docs/07-auth-state.md +0 -0
  26. package/docs/08-clock-mocking.md +0 -0
  27. package/docs/09-api-testing.md +0 -0
  28. package/docs/10-accessibility.md +24 -3
  29. package/docs/11-debugging.md +0 -0
  30. package/docs/12-ai-agent-guide.md +0 -0
  31. package/docs/13-faq.md +0 -0
  32. package/docs/14-recipes-cookbook.md +0 -0
  33. package/docs/15-tag-conventions.md +0 -0
  34. package/docs/16-ci-cd.md +0 -0
  35. package/docs/README.md +6 -3
  36. package/docs/advanced-screenshots/then-i-save-fullscreen-screenshot.md +0 -0
  37. package/docs/advanced-screenshots/then-i-save-width-x-height-screenshot.md +0 -0
  38. package/docs/advanced-screenshots/when-i-save-screenshot-name-filename.md +0 -0
  39. package/docs/advanced-screenshots.md +0 -0
  40. package/docs/advanced-selectors.md +0 -0
  41. package/docs/api-step-definitions.md +0 -0
  42. package/docs/global-settings.md +1 -28
  43. package/docs/install-webship-js/ddev-webship-js.md +0 -0
  44. package/docs/install-webship-js.md +0 -1
  45. package/docs/overview.md +0 -1
  46. package/docs/step-definitions/given-i-am-anonymous-user.md +0 -0
  47. package/docs/step-definitions/given-i-am-homepage.md +0 -0
  48. package/docs/step-definitions/given-i-am-specific-page.md +0 -0
  49. package/docs/step-definitions/then-i-should-be.md +0 -0
  50. package/docs/step-definitions/then-i-should-see.md +0 -0
  51. package/docs/step-definitions/then-item-checkbox.md +0 -0
  52. package/docs/step-definitions/then-item-link-should-contain-url.md +0 -0
  53. package/docs/step-definitions/then-item-should-contain.md +0 -0
  54. package/docs/step-definitions/then-radio-button-value-should-be-selected.md +0 -0
  55. package/docs/step-definitions/then-response-status-code-should-be-number.md +0 -0
  56. package/docs/step-definitions/then-value-radio-button-selected.md +0 -0
  57. package/docs/step-definitions/when-i-attach-file-file-name-element.md +0 -0
  58. package/docs/step-definitions/when-i-check-checkbox.md +0 -0
  59. package/docs/step-definitions/when-i-click-link.md +0 -0
  60. package/docs/step-definitions/when-i-click-operation-text-row.md +0 -0
  61. package/docs/step-definitions/when-i-fill.md +0 -0
  62. package/docs/step-definitions/when-i-go-homepage.md +0 -0
  63. package/docs/step-definitions/when-i-go-specific-page.md +0 -0
  64. package/docs/step-definitions/when-i-move-backward-one-page.md +0 -0
  65. package/docs/step-definitions/when-i-move-forward-one-page.md +0 -0
  66. package/docs/step-definitions/when-i-press-button.md +0 -0
  67. package/docs/step-definitions/when-i-reload-page.md +0 -0
  68. package/docs/step-definitions/when-i-scroll.md +0 -0
  69. package/docs/step-definitions/when-i-select-option-select-list.md +0 -0
  70. package/docs/step-definitions/when-i-select-radio-button-value.md +0 -0
  71. package/docs/step-definitions/when-i-uncheck-checkbox.md +0 -0
  72. package/docs/step-definitions/when-i-wait-ajax-finish.md +0 -0
  73. package/docs/step-definitions/when-i-wait.md +0 -0
  74. package/docs/step-definitions.md +0 -0
  75. package/examples/a11y.html +8 -0
  76. package/examples/account.html +0 -0
  77. package/examples/ajax-wait-examples.html +0 -0
  78. package/examples/cookies.html +0 -0
  79. package/examples/date.html +0 -0
  80. package/examples/dynamic-examples.html +0 -0
  81. package/examples/element.html +0 -0
  82. package/examples/field.html +0 -0
  83. package/examples/keyboard.html +0 -0
  84. package/examples/links.html +0 -0
  85. package/examples/modal.html +0 -0
  86. package/examples/never-settles.html +32 -0
  87. package/examples/path.html +0 -0
  88. package/examples/table.html +0 -0
  89. package/examples/test--modal-dialogs.html +0 -0
  90. package/examples/test--when--i-additionally-select.html +0 -0
  91. package/examples/test--when--i-select-radio-button.html +0 -0
  92. package/examples/video-demo.html +0 -0
  93. package/package.json +1 -1
  94. package/playwright.config.ts +0 -0
  95. package/tests/assets/test-document.pdf +0 -0
  96. package/tests/features/a11y.feature +22 -0
  97. package/tests/features/ajax-wait-examples.feature +0 -0
  98. package/tests/features/cookie.feature +0 -0
  99. package/tests/features/date.feature +0 -0
  100. package/tests/features/dynamic-content-examples.feature +0 -0
  101. package/tests/features/element.feature +0 -0
  102. package/tests/features/field.feature +0 -0
  103. package/tests/features/keyboard.feature +0 -0
  104. package/tests/features/link.feature +0 -0
  105. package/tests/features/modal-advanced-example.feature +0 -0
  106. package/tests/features/modal-basic-example.feature +0 -0
  107. package/tests/features/modal-error-handling-example.feature +0 -0
  108. package/tests/features/modal.feature +0 -0
  109. package/tests/features/path.feature +0 -0
  110. package/tests/features/response.feature +0 -0
  111. package/tests/features/responsive.feature +0 -0
  112. package/tests/features/smart-settle-budget.feature +12 -0
  113. package/tests/features/table.feature +0 -0
  114. package/tests/features/test--given--i-am-an-anonymous-user.feature +0 -0
  115. package/tests/features/test--then--i-save-screenshot.feature +0 -0
  116. package/tests/features/test--then--i-see-locator.feature +0 -0
  117. package/tests/features/test--then--i-should-see-n-elements.feature +0 -0
  118. package/tests/features/test--then--print-current-url-and-response.feature +0 -0
  119. package/tests/features/test--when--i-additionally-select.feature +0 -0
  120. package/tests/features/test--when--i-follow.feature +0 -0
  121. package/tests/features/test--when--i-select-radio-button.feature +0 -0
  122. package/tests/features/video.feature +0 -0
  123. package/tests/features/wait.feature +0 -0
  124. package/tests/features/yaml.feature +0 -0
  125. package/tests/reports/README.md +0 -0
  126. package/tests/selectors/_canonical-keys.json +0 -0
  127. package/tests/selectors/back-end-selectors.json +0 -0
  128. package/tests/selectors/cms-contentful-admin.json +0 -0
  129. package/tests/selectors/cms-craft-admin.json +0 -0
  130. package/tests/selectors/cms-drupal-cms-gin.json +0 -0
  131. package/tests/selectors/cms-drupal-core-claro.json +0 -0
  132. package/tests/selectors/cms-generic-admin.json +0 -0
  133. package/tests/selectors/cms-ghost-admin.json +0 -0
  134. package/tests/selectors/cms-joomla-admin.json +0 -0
  135. package/tests/selectors/cms-magento2-admin.json +0 -0
  136. package/tests/selectors/cms-prestashop-admin.json +0 -0
  137. package/tests/selectors/cms-shopify-admin.json +0 -0
  138. package/tests/selectors/cms-strapi-admin.json +0 -0
  139. package/tests/selectors/cms-typo3-admin.json +0 -0
  140. package/tests/selectors/cms-woocommerce-front.json +0 -0
  141. package/tests/selectors/cms-wordpress-admin.json +0 -0
  142. package/tests/selectors/framework-ant-design.json +0 -0
  143. package/tests/selectors/framework-bootstrap.json +0 -0
  144. package/tests/selectors/framework-bulma.json +0 -0
  145. package/tests/selectors/framework-chakra.json +0 -0
  146. package/tests/selectors/framework-foundation.json +0 -0
  147. package/tests/selectors/framework-material-ui.json +0 -0
  148. package/tests/selectors/framework-shadcn.json +0 -0
  149. package/tests/selectors/framework-tailwind.json +0 -0
  150. package/tests/selectors/framework-vuetify.json +0 -0
  151. package/tests/selectors/front-end-selectors.json +0 -0
  152. package/tests/selectors/homepage-selectors.json +0 -0
  153. package/tests/step-definitions/a11y.steps.js +339 -113
  154. package/tests/step-definitions/action.steps.js +0 -0
  155. package/tests/step-definitions/assertion.steps.js +0 -0
  156. package/tests/step-definitions/auth.steps.js +0 -0
  157. package/tests/step-definitions/clock.steps.js +0 -0
  158. package/tests/step-definitions/cookie.steps.js +0 -0
  159. package/tests/step-definitions/debug.steps.js +0 -0
  160. package/tests/step-definitions/dialog.steps.js +0 -0
  161. package/tests/step-definitions/element.steps.js +0 -0
  162. package/tests/step-definitions/field.steps.js +0 -0
  163. package/tests/step-definitions/file-download.steps.js +0 -0
  164. package/tests/step-definitions/form.steps.js +0 -0
  165. package/tests/step-definitions/iframe.steps.js +0 -0
  166. package/tests/step-definitions/input.steps.js +0 -0
  167. package/tests/step-definitions/javascript.steps.js +0 -0
  168. package/tests/step-definitions/keyboard.steps.js +0 -0
  169. package/tests/step-definitions/link.steps.js +0 -0
  170. package/tests/step-definitions/metatag.steps.js +0 -0
  171. package/tests/step-definitions/modal.steps.js +0 -0
  172. package/tests/step-definitions/navigation.steps.js +0 -0
  173. package/tests/step-definitions/network.steps.js +0 -0
  174. package/tests/step-definitions/path.steps.js +0 -0
  175. package/tests/step-definitions/response.steps.js +0 -0
  176. package/tests/step-definitions/responsive.steps.js +0 -0
  177. package/tests/step-definitions/rest.steps.js +0 -0
  178. package/tests/step-definitions/screenshot.steps.js +0 -0
  179. package/tests/step-definitions/scroll.steps.js +0 -0
  180. package/tests/step-definitions/selectors.steps.js +0 -0
  181. package/tests/step-definitions/storage.steps.js +0 -0
  182. package/tests/step-definitions/table.steps.js +0 -0
  183. package/tests/step-definitions/video.steps.js +0 -0
  184. package/tests/step-definitions/wait.steps.js +0 -0
  185. package/tests/step-definitions/web-first.steps.js +0 -0
  186. package/tests/step-definitions/webship.js +57 -20
  187. package/tests/step-definitions/xml.steps.js +0 -0
  188. package/tests/step-definitions/yaml.steps.js +0 -0
  189. package/tsconfig.json +0 -0
  190. package/videos/README.md +0 -0
  191. package/docs/diffy-step-definitions/then-compare-diffy-env1-env2.md +0 -30
  192. package/docs/diffy-step-definitions/then-create-diffy-comparison-name-value.md +0 -21
  193. package/docs/diffy-step-definitions/then-create-diffy-comparison.md +0 -25
  194. package/docs/diffy-step-definitions/then-create-diffy-screenshot-environment-name.md +0 -35
  195. package/docs/diffy-step-definitions/then-i-take-screenshot.md +0 -21
  196. package/docs/diffy-step-definitions/then-i-take-screenshots-all-breakpoints.md +0 -27
  197. package/docs/diffy-step-definitions/then-send-screenshots-diffy-name-value.md +0 -27
  198. package/docs/diffy-step-definitions/then-upload-folder-url-diffy-snapshotname.md +0 -28
  199. package/docs/diffy-step-definitions/then-wait-diffy-comparison-complete.md +0 -21
  200. package/docs/diffy-step-definitions/when-i-resize-window-number.md +0 -29
  201. package/docs/diffy-step-definitions.md +0 -21
  202. package/examples/diffy/baseline.html +0 -54
  203. package/examples/diffy/changed.html +0 -63
  204. package/examples/diffy/index.html +0 -52
  205. package/tests/features/diffy/test--diffy-01-example-demo.feature +0 -22
  206. package/tests/features/diffy/test--diffy-02-all-steps.feature +0 -52
  207. package/tests/features/diffy/test--diffy-03-real-api.feature +0 -21
  208. package/tests/step-definitions-diffy/README.md +0 -329
  209. package/tests/step-definitions-diffy/mock-diffy-api/server.js +0 -84
  210. package/tests/step-definitions-diffy/webship-diffy-mock.js +0 -31
  211. package/tests/step-definitions-diffy/webship-diffy.js +0 -459
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -69,10 +69,27 @@ if (process.env.WEBSHIP_FILTER_HOOK_LINES !== 'off') {
69
69
  // late-firing setTimeout that mutates the DOM re-arms the wait correctly.
70
70
  // ---------------------------------------------------------------------------
71
71
 
72
+ /**
73
+ * Smallest timeout worth handing to Playwright. Playwright reads `timeout: 0`
74
+ * as "no timeout at all", so a spent budget must never reach it as a zero —
75
+ * that is how a settle could wait forever instead of giving up.
76
+ *
77
+ * @type {number}
78
+ */
79
+ const SETTLE_MIN_MS = 25;
80
+
72
81
  /**
73
82
  * Wait for the page to reach an "edge" of activity — DOM ready, network
74
83
  * idle, no pending AJAX or timers, and no DOM mutations for ≥250 ms.
75
84
  *
85
+ * Each stage gets a share of the budget rather than "whatever is left", so a
86
+ * stage that can never resolve cannot starve the ones after it. On a page with
87
+ * analytics, a chat widget or a self-rescheduling timer, `networkidle` never
88
+ * arrives; capping it at half the budget keeps the AJAX / pending-timer /
89
+ * DOM-quiet probe — the useful one — running.
90
+ *
91
+ * Returns within `timeout` ms even when nothing on the page ever settles.
92
+ *
76
93
  * @param {import('playwright').Page} page - Page being probed.
77
94
  * @param {number} [timeout=10000] - Total budget in ms.
78
95
  * @returns {Promise<void>}
@@ -80,26 +97,38 @@ if (process.env.WEBSHIP_FILTER_HOOK_LINES !== 'off') {
80
97
  async function smartSettle(page, timeout) {
81
98
  const total = typeof timeout === 'number' && timeout > 0 ? timeout : 10000;
82
99
  const deadline = Date.now() + total;
83
- const remaining = () => Math.max(0, deadline - Date.now());
84
100
 
85
- try { await page.waitForSelector('body', { state: 'attached', timeout: remaining() }); } catch { /* keep going */ }
86
- try { await page.waitForLoadState('domcontentloaded', { timeout: remaining() }); } catch { /* keep going */ }
87
- try { await page.waitForLoadState('networkidle', { timeout: remaining() }); } catch { /* keep going */ }
88
- try {
89
- await page.waitForFunction(
90
- (quietMs) => {
91
- const ajax = window.__webshipAjaxCount;
92
- const timers = window.__webshipPendingTimers;
93
- const last = window.__webshipLastMutation;
94
- if (typeof ajax === 'number' && ajax > 0) return false;
95
- if (typeof timers === 'number' && timers > 0) return false;
96
- if (typeof last === 'number' && Date.now() - last < quietMs) return false;
97
- return true;
98
- },
99
- 250,
100
- { timeout: remaining(), polling: 50 }
101
- );
102
- } catch { /* keep going */ }
101
+ // Milliseconds left in the budget. Never handed to Playwright directly: a
102
+ // zero there means "no timeout", not "return immediately".
103
+ const left = () => deadline - Date.now();
104
+
105
+ // Run one stage with at most `share` of the original budget, and never more
106
+ // than what is actually left. Returns false once the budget is spent, so the
107
+ // caller stops instead of calling Playwright with a useless timeout.
108
+ const stage = async (share, fn) => {
109
+ const remaining = left();
110
+ if (remaining < SETTLE_MIN_MS) return false;
111
+ const budget = Math.max(SETTLE_MIN_MS, Math.min(remaining, Math.round(total * share)));
112
+ try { await fn(budget); } catch { /* a stage timing out is not a failure */ }
113
+ return left() >= SETTLE_MIN_MS;
114
+ };
115
+
116
+ if (!await stage(0.25, (t) => page.waitForSelector('body', { state: 'attached', timeout: t }))) return;
117
+ if (!await stage(0.25, (t) => page.waitForLoadState('domcontentloaded', { timeout: t }))) return;
118
+ if (!await stage(0.5, (t) => page.waitForLoadState('networkidle', { timeout: t }))) return;
119
+ await stage(0.5, (t) => page.waitForFunction(
120
+ (quietMs) => {
121
+ const ajax = window.__webshipAjaxCount;
122
+ const timers = window.__webshipPendingTimers;
123
+ const last = window.__webshipLastMutation;
124
+ if (typeof ajax === 'number' && ajax > 0) return false;
125
+ if (typeof timers === 'number' && timers > 0) return false;
126
+ if (typeof last === 'number' && Date.now() - last < quietMs) return false;
127
+ return true;
128
+ },
129
+ 250,
130
+ { timeout: t, polling: 50 }
131
+ ));
103
132
  }
104
133
 
105
134
  /**
@@ -620,7 +649,15 @@ if (!global.__WEBSHIP_AUTO_REPORT__) {
620
649
  // (e.g. click() with no match) reach our try/catch wrappers BEFORE cucumber
621
650
  // trips its own timeout — otherwise testers see "function timed out" instead
622
651
  // of the friendly Why/Hint message.
623
- setDefaultTimeout(45 * 1000);
652
+ //
653
+ // setDefaultTimeout() runs at load time and overrides whatever `timeout` a
654
+ // consumer set in their own cucumber.js, so WEBSHIP_STEP_TIMEOUT is the
655
+ // way to raise (or lower) it from outside. 45s stays the default.
656
+ const STEP_TIMEOUT = (() => {
657
+ const raw = parseInt(process.env.WEBSHIP_STEP_TIMEOUT, 10);
658
+ return Number.isFinite(raw) && raw > 0 ? raw : 45 * 1000;
659
+ })();
660
+ setDefaultTimeout(STEP_TIMEOUT);
624
661
 
625
662
  class PlaywrightWorld extends World {
626
663
  constructor(options) {
File without changes
File without changes
package/tsconfig.json CHANGED
File without changes
package/videos/README.md CHANGED
File without changes
@@ -1,30 +0,0 @@
1
-
2
- # Then compare diffy "ENV1" with "ENV2"
3
-
4
- ## Description
5
-
6
- This step initiates a Diffy comparison between two project environments. When either environment is specified as "custom", the step uses the `DIFFY_ENV1_URL` and `DIFFY_ENV2_URL` environment variables.
7
-
8
- ## Gherkin Step Pattern
9
-
10
- ```
11
- Then (I |we )*compare diffy "([^"]*)" with "([^"]*)"
12
- ```
13
-
14
- ## Examples
15
-
16
- ```
17
- Then compare diffy "prod" with "stage"
18
- Then compare diffy "production" with "staging"
19
- Then compare diffy "prod" with "dev"
20
- Then compare diffy "stage" with "dev"
21
- Then compare diffy "prod" with "baseline"
22
- Then compare diffy "baseline" with "custom"
23
- Then compare diffy "custom" with "custom"
24
- Then compare diffy "production" with "development"
25
- ```
26
-
27
- ## Parameters
28
-
29
- - **First Environment**: The initial environment name for comparison
30
- - **Second Environment**: The environment to compare against (uses custom URLs when "custom" is specified)
@@ -1,21 +0,0 @@
1
-
2
- # Then create diffy comparison with name "value"
3
-
4
- ## Description
5
- This step definition creates a named Diffy comparison using the last two uploaded snapshots.
6
-
7
- ## Gherkin Pattern
8
- ```
9
- Then (I |we )*create diffy comparison with name "([^"]*)"
10
- ```
11
-
12
- ## Examples
13
- - `Then create diffy comparison with name "release-2.0"`
14
- - `Then create diffy comparison with name "nightly"`
15
- - `Then create diffy comparison with name "smoke-run-42"`
16
- - `Then create diffy comparison with name "webship.co-regression"`
17
- - `Then create diffy comparison with name "before-vs-after"`
18
- - `Then create diffy comparison with name "homepage-baseline-vs-changed"`
19
-
20
- ## Parameters
21
- The step accepts a single parameter: a string value representing the name for the comparison being created.
@@ -1,25 +0,0 @@
1
-
2
- # Then create diffy comparison
3
-
4
- ## Description
5
- This step generates a Diffy comparison (visual diff) by utilizing the two most recently uploaded snapshots.
6
-
7
- ## Gherkin Syntax
8
- ```gherkin
9
- Then (I |we )*create diffy comparison
10
- ```
11
-
12
- ## Usage Examples
13
- The step accepts several grammatical variations:
14
-
15
- ```gherkin
16
- Then create diffy comparison
17
- And create diffy comparison
18
- Then I create diffy comparison
19
- Then we create diffy comparison
20
- And I create diffy comparison
21
- And we create diffy comparison
22
- ```
23
-
24
- ## Purpose
25
- Creates a visual comparison report from the last pair of snapshots that were uploaded to Diffy, allowing teams to identify visual regressions between environments or versions.
@@ -1,35 +0,0 @@
1
-
2
- # Then create diffy screenshot from "environment name" environment
3
-
4
- ## Overview
5
-
6
- This Webship JS step definition instructs Diffy to capture a snapshot remotely from a specified environment within your project. The step accepts both abbreviated and full environment names, including custom environments.
7
-
8
- ## Gherkin Step Pattern
9
-
10
- ```
11
- Then (I |we )*create diffy screenshot from "([^"]*)" environment
12
- ```
13
-
14
- ## Description
15
-
16
- "Ask Diffy to capture a snapshot remotely from a named environment on the project. Accepts short (prod/stage/dev) or long (production/staging/development) forms, plus 'custom'."
17
-
18
- ## Examples
19
-
20
- ```gherkin
21
- Then create diffy screenshot from "production" environment
22
- Then create diffy screenshot from "prod" environment
23
- Then create diffy screenshot from "staging" environment
24
- Then create diffy screenshot from "stage" environment
25
- Then create diffy screenshot from "development" environment
26
- Then create diffy screenshot from "dev" environment
27
- Then create diffy screenshot from "custom" environment
28
- ```
29
-
30
- ## Supported Environment Names
31
-
32
- - **Production**: "production" or "prod"
33
- - **Staging**: "staging" or "stage"
34
- - **Development**: "development" or "dev"
35
- - **Custom**: "custom" (for user-defined environments)
@@ -1,21 +0,0 @@
1
-
2
- # Then I take screenshot
3
-
4
- ## Description
5
-
6
- "Capture a full-page screenshot at the current viewport. Held in-memory (and optionally written to DIFFY_SCREENSHOTS_DIR) until 'send screenshots to diffy with name' uploads the batch."
7
-
8
- ## Gherkin Step Definition
9
-
10
- ```
11
- Then(/^(?:I |we )?take screenshot$)
12
- ```
13
-
14
- ## Usage Examples
15
-
16
- - `Then I take screenshot`
17
- - `Then we take screenshot`
18
- - `And I take screenshot`
19
- - `And we take screenshot`
20
- - `Then take screenshot`
21
- - `And take screenshot`
@@ -1,27 +0,0 @@
1
-
2
- # Then I take screenshots for all breakpoints
3
-
4
- ## Description
5
-
6
- This step definition resizes the browser window to each configured breakpoint and captures a screenshot at each breakpoint. The breakpoints are sourced from the `DIFFY_BREAKPOINTS` environment variable or `worldParameters.diffy.breakpoints`.
7
-
8
- ## Gherkin Step Pattern
9
-
10
- ```
11
- Then(/^(?:I |we )?take screenshots for all breakpoints$)
12
- ```
13
-
14
- ## Usage Examples
15
-
16
- - `Then I take screenshots for all breakpoints`
17
- - `Then we take screenshots for all breakpoints`
18
- - `And I take screenshots for all breakpoints`
19
- - `And we take screenshots for all breakpoints`
20
- - `Then take screenshots for all breakpoints`
21
- - `And take screenshots for all breakpoints`
22
-
23
- ## Configuration
24
-
25
- Breakpoints are configured via:
26
- - `DIFFY_BREAKPOINTS` environment variable, or
27
- - `worldParameters.diffy.breakpoints` parameter
@@ -1,27 +0,0 @@
1
-
2
- # Then send screenshots to diffy with name "value"
3
-
4
- ## Overview
5
- This step definition uploads all captured screenshots to Diffy as a named custom snapshot. Upon successful execution, it clears both the in-memory buffer and on-disk screenshotsDir.
6
-
7
- ## Gherkin Pattern
8
- ```
9
- Then (I |we )*send screenshots to diffy with name "([^"]*)"
10
- ```
11
-
12
- ## Examples
13
-
14
- ```
15
- Then send screenshots to diffy with name "baseline"
16
- Then send screenshots to diffy with name "changed"
17
- Then send screenshots to diffy with name "homepage-release-2.0"
18
- Then send screenshots to diffy with name "after-deploy"
19
- Then send screenshots to diffy with name "smoke-run"
20
- Then send screenshots to diffy with name "webship.co-prod"
21
- ```
22
-
23
- ## Parameters
24
- - **name** (required): A custom snapshot identifier string passed in quotes
25
-
26
- ## Functionality
27
- The step captures all previously taken screenshots and uploads them to Diffy with the specified snapshot name. After successful upload, it automatically clears both the internal screenshot buffer and the local screenshots directory.
@@ -1,28 +0,0 @@
1
-
2
- # Then upload folder "URL" to diffy as "snapshotName"
3
-
4
- ## Description
5
-
6
- This step uploads all PNG and WebP images from a local directory to Diffy as a named custom snapshot. The breakpoint dimensions are extracted from image width metadata, while the URL slug is determined from the filename.
7
-
8
- ## Gherkin Pattern
9
-
10
- ```
11
- Then (I |we )*upload folder "([^"]*)" to diffy as "([^"]*)"
12
- ```
13
-
14
- ## Examples
15
-
16
- ```gherkin
17
- Then upload folder "./screenshots/baseline" to diffy as "baseline"
18
- Then upload folder "./screenshots/changed" to diffy as "changed"
19
- Then upload folder "./reports/screenshots" to diffy as "nightly"
20
- Then upload folder "/tmp/webship-shots" to diffy as "webship.co-snapshot"
21
- Then upload folder "./out/homepage" to diffy as "homepage-release-2.0"
22
- Then upload folder "./diffy/before" to diffy as "before-deploy"
23
- ```
24
-
25
- ## Parameters
26
-
27
- - **Folder Path**: Local directory containing PNG/WebP files (required)
28
- - **Snapshot Name**: Label for the uploaded custom snapshot in Diffy (required)
@@ -1,21 +0,0 @@
1
-
2
- # Then wait for diffy comparison to complete
3
-
4
- ## Description
5
-
6
- This step polls the most recently created Diffy comparison until it reaches a terminal state. The default timeout is set to `DIFFY_MAX_WAIT` seconds, which defaults to 1200 seconds.
7
-
8
- ## Gherkin Syntax
9
-
10
- ```
11
- Then (I |we )*wait for diffy comparison to complete
12
- ```
13
-
14
- ## Examples
15
-
16
- - `Then wait for diffy comparison to complete`
17
- - `And wait for diffy comparison to complete`
18
- - `Then I wait for diffy comparison to complete`
19
- - `Then we wait for diffy comparison to complete`
20
- - `And I wait for diffy comparison to complete`
21
- - `And we wait for diffy comparison to complete`
@@ -1,29 +0,0 @@
1
-
2
- # When I resize window to "number"
3
-
4
- ## Step Definition
5
-
6
- ```
7
- When(/^(?:I |we )?resize window to "([^"]*)")
8
- ```
9
-
10
- ## Description
11
-
12
- "Resize browser viewport to a breakpoint width (plus Diffy window padding)."
13
-
14
- ## Examples
15
-
16
- ```
17
- When I resize window to "1200"
18
- When we resize window to "640"
19
- When I resize window to "320"
20
- When we resize window to "768"
21
- When I resize window to "1024"
22
- When we resize window to "1440"
23
- When I resize window to "1920"
24
- When we resize window to "375"
25
- ```
26
-
27
- ## Parameters
28
-
29
- - `number`: The viewport width in pixels to resize the browser window to
@@ -1,21 +0,0 @@
1
-
2
- # Diffy Step Definitions
3
-
4
- ## Overview
5
-
6
- This documentation page describes Diffy Step Definitions for Webship JS 2.0.x. The feature enables opt-in visual-regression testing capabilities, allowing developers to capture full-page Playwright screenshots at multiple breakpoints and upload them to Diffy for comparison via REST API.
7
-
8
- **Key characteristic:** "Kept in a separate folder (tests/step-definitions-diffy/) so the default npm test run does not load them."
9
-
10
- ## Available Step Definitions
11
-
12
- - [Then I take screenshot](/docs/webship-js/2.0.x/diffy-step-definitions/then-i-take-screenshot)
13
- - [Then I take screenshots for all breakpoints](/docs/webship-js/2.0.x/diffy-step-definitions/then-i-take-screenshots-all-breakpoints)
14
- - [Then compare diffy "ENV1" with "ENV2"](/docs/webship-js/2.0.x/diffy-step-definitions/then-compare-diffy-env1-env2)
15
- - [Then create diffy comparison](/docs/webship-js/2.0.x/diffy-step-definitions/then-create-diffy-comparison)
16
- - [Then create diffy comparison with name "value"](/docs/webship-js/2.0.x/diffy-step-definitions/then-create-diffy-comparison-name-value)
17
- - [Then create diffy screenshot from "environment name" environment](/docs/webship-js/2.0.x/diffy-step-definitions/then-create-diffy-screenshot-environment-name)
18
- - [Then send screenshots to diffy with name "value"](/docs/webship-js/2.0.x/diffy-step-definitions/then-send-screenshots-diffy-name-value)
19
- - [Then upload folder "URL" to diffy as "snapshotName"](/docs/webship-js/2.0.x/diffy-step-definitions/then-upload-folder-url-diffy-snapshotname)
20
- - [Then wait for diffy comparison to complete](/docs/webship-js/2.0.x/diffy-step-definitions/then-wait-diffy-comparison-complete)
21
- - [When I resize window to "number"](/docs/webship-js/2.0.x/diffy-step-definitions/when-i-resize-window-number)
@@ -1,54 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>Diffy Example — Baseline</title>
7
- <style>
8
- body { font-family: system-ui, sans-serif; margin: 0; color: #222; }
9
- header { background: #1e40af; color: #fff; padding: 24px 32px; }
10
- header h1 { margin: 0; font-size: 28px; }
11
- nav { background: #eef2ff; padding: 12px 32px; }
12
- nav a { margin-right: 16px; color: #1e40af; text-decoration: none; }
13
- main { padding: 32px; max-width: 960px; margin: 0 auto; }
14
- .card {
15
- background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
16
- padding: 20px; margin-bottom: 16px;
17
- }
18
- .card h2 { margin-top: 0; color: #1e40af; }
19
- .cta {
20
- display: inline-block; background: #1e40af; color: #fff;
21
- padding: 10px 20px; border-radius: 6px; text-decoration: none;
22
- }
23
- footer { background: #f3f4f6; padding: 16px 32px; color: #6b7280; font-size: 14px; }
24
- </style>
25
- </head>
26
- <body>
27
- <header>
28
- <h1>Webship-JS — Diffy Baseline</h1>
29
- <p>Stable layout captured as the reference snapshot.</p>
30
- </header>
31
- <nav>
32
- <a href="../index.html">Home</a>
33
- <a href="index.html">Diffy index</a>
34
- <a href="baseline.html">Baseline</a>
35
- <a href="changed.html">Changed</a>
36
- </nav>
37
- <main>
38
- <div class="card">
39
- <h2>Feature A</h2>
40
- <p>Baseline copy for feature A. This block is unchanged between versions.</p>
41
- </div>
42
- <div class="card">
43
- <h2>Feature B</h2>
44
- <p>Original baseline copy. Diffy should flag differences on the changed page.</p>
45
- <a class="cta" href="#">Call to action</a>
46
- </div>
47
- <div class="card">
48
- <h2>Pricing</h2>
49
- <p>Plan: <strong>$19/month</strong></p>
50
- </div>
51
- </main>
52
- <footer>&copy; 2026 Webship-JS Diffy example — baseline</footer>
53
- </body>
54
- </html>
@@ -1,63 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>Diffy Example — Changed</title>
7
- <style>
8
- body { font-family: system-ui, sans-serif; margin: 0; color: #222; }
9
- header { background: #b91c1c; color: #fff; padding: 24px 32px; }
10
- header h1 { margin: 0; font-size: 32px; }
11
- nav { background: #fee2e2; padding: 12px 32px; }
12
- nav a { margin-right: 16px; color: #b91c1c; text-decoration: none; }
13
- main { padding: 32px; max-width: 960px; margin: 0 auto; }
14
- .card {
15
- background: #fff; border: 2px solid #fca5a5; border-radius: 12px;
16
- padding: 24px; margin-bottom: 20px;
17
- }
18
- .card h2 { margin-top: 0; color: #b91c1c; }
19
- .cta {
20
- display: inline-block; background: #b91c1c; color: #fff;
21
- padding: 12px 28px; border-radius: 999px; text-decoration: none;
22
- font-weight: bold;
23
- }
24
- .badge {
25
- display: inline-block; background: #fbbf24; color: #7c2d12;
26
- padding: 4px 10px; border-radius: 4px; font-size: 13px; margin-left: 8px;
27
- }
28
- footer { background: #fef2f2; padding: 16px 32px; color: #7f1d1d; font-size: 14px; }
29
- </style>
30
- </head>
31
- <body>
32
- <header>
33
- <h1>Webship-JS — Diffy Changed <span style="font-size:14px;">(v2)</span></h1>
34
- <p>Layout + palette shifted. Diffy should report regressions vs baseline.</p>
35
- </header>
36
- <nav>
37
- <a href="../index.html">Home</a>
38
- <a href="index.html">Diffy index</a>
39
- <a href="baseline.html">Baseline</a>
40
- <a href="changed.html">Changed</a>
41
- </nav>
42
- <main>
43
- <div class="card">
44
- <h2>Feature A</h2>
45
- <p>Baseline copy for feature A. This block is unchanged between versions.</p>
46
- </div>
47
- <div class="card">
48
- <h2>Feature B <span class="badge">NEW</span></h2>
49
- <p><strong>Redesigned</strong> copy with a new badge and fatter card padding.</p>
50
- <a class="cta" href="#">Buy now</a>
51
- </div>
52
- <div class="card">
53
- <h2>Pricing</h2>
54
- <p>Plan: <strong>$29/month</strong> (was $19)</p>
55
- </div>
56
- <div class="card">
57
- <h2>Testimonials</h2>
58
- <p>Entirely new section — Diffy should flag this as added content.</p>
59
- </div>
60
- </main>
61
- <footer>&copy; 2026 Webship-JS Diffy example — changed build</footer>
62
- </body>
63
- </html>
@@ -1,52 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>Diffy examples — Webship-JS</title>
7
- <style>
8
- body { font-family: system-ui, sans-serif; margin: 0; color: #222; }
9
- header { background: #0f172a; color: #fff; padding: 24px 32px; }
10
- header h1 { margin: 0; font-size: 26px; }
11
- main { padding: 32px; max-width: 820px; margin: 0 auto; }
12
- .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
13
- .pair a {
14
- display: block; padding: 20px; border-radius: 8px;
15
- text-decoration: none; color: #fff;
16
- }
17
- .pair a.base { background: #1e40af; }
18
- .pair a.changed { background: #b91c1c; }
19
- .pair h2 { margin: 0 0 8px 0; }
20
- .pair small { opacity: 0.85; }
21
- p { line-height: 1.5; }
22
- code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }
23
- footer { background: #f3f4f6; padding: 14px 32px; color: #6b7280; font-size: 14px; }
24
- a.back { color: #1e40af; }
25
- </style>
26
- </head>
27
- <body>
28
- <header>
29
- <h1>Webship-JS — Diffy visual-regression examples</h1>
30
- </header>
31
- <main>
32
- <p><a class="back" href="/">&larr; Back to examples index</a></p>
33
- <p>
34
- Two deliberately different pages. Run
35
- <code>npx cucumber-js --config cucumber.js -p diffy</code>
36
- (against a mock or real Diffy API) to capture screenshots of both pages
37
- at each breakpoint and request a comparison.
38
- </p>
39
- <div class="pair">
40
- <a class="base" href="baseline.html">
41
- <h2>Baseline</h2>
42
- <small>Reference snapshot — blue palette, rect CTA, $19/mo</small>
43
- </a>
44
- <a class="changed" href="changed.html">
45
- <h2>Changed</h2>
46
- <small>Visible regressions — red palette, NEW badge, pill CTA, $29/mo, added Testimonials</small>
47
- </a>
48
- </div>
49
- </main>
50
- <footer>&copy; 2026 Webship-JS Diffy examples</footer>
51
- </body>
52
- </html>
@@ -1,22 +0,0 @@
1
- Feature: Diffy — example pages demo
2
- Drive the bundled /diffy/baseline.html and /diffy/changed.html example
3
- pages through the Diffy capture + comparison flow. Safe to run against
4
- the mock Diffy API for local development.
5
-
6
- Config resolution (per-scenario):
7
- 1. process.env.DIFFY_*
8
- 2. cucumber.js worldParameters.diffy.*
9
- 3. built-in defaults
10
-
11
- @diffy @example
12
- Scenario: Capture baseline and changed, send to diffy, compare
13
- Given I am on "/diffy/baseline.html"
14
- Then I take screenshots for all breakpoints
15
- Then send screenshots to diffy with name "example-baseline"
16
-
17
- Given I am on "/diffy/changed.html"
18
- Then I take screenshots for all breakpoints
19
- Then send screenshots to diffy with name "example-changed"
20
-
21
- Then create diffy comparison with name "example-demo"
22
- Then wait for diffy comparison to complete