webship-js 2.0.10 → 2.0.12

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 (248) hide show
  1. package/.circleci/config.yml +10 -1
  2. package/.drone.yml +7 -7
  3. package/.github/ISSUE_TEMPLATE/issue.md +37 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +24 -0
  5. package/.github/workflows/github-actions.yml +101 -4
  6. package/.gitlab-ci.yml +9 -4
  7. package/.harness/webship-js-pipeline.yml +5 -6
  8. package/.semaphore/semaphore.yml +6 -9
  9. package/.teamcity/settings.kts +7 -6
  10. package/.travis.yml +6 -1
  11. package/AGENTS.md +1 -1
  12. package/CLAUDE.md +69 -24
  13. package/Jenkinsfile +5 -3
  14. package/README.md +13 -1
  15. package/azure-pipelines.yml +17 -8
  16. package/bamboo-specs/bamboo.yml +9 -15
  17. package/bin/generate-reports.js +51 -7
  18. package/bin/init-webship.js +127 -23
  19. package/bitbucket-pipelines.yml +5 -1
  20. package/buildspec.yml +6 -7
  21. package/cloudbuild.yaml +28 -12
  22. package/codefresh.yml +6 -6
  23. package/cucumber.js +46 -11
  24. package/docs/00-quick-start.md +38 -7
  25. package/docs/02-bbr-smart-waits.md +21 -10
  26. package/docs/03-selector-registry.md +24 -0
  27. package/docs/04-step-reference.md +53 -27
  28. package/docs/05-web-first-assertions.md +6 -0
  29. package/docs/07-auth-state.md +1 -1
  30. package/docs/08-clock-mocking.md +21 -2
  31. package/docs/09-api-testing.md +40 -2
  32. package/docs/10-accessibility.md +2 -0
  33. package/docs/11-debugging.md +24 -1
  34. package/docs/12-ai-agent-guide.md +8 -1
  35. package/docs/13-faq.md +75 -1
  36. package/docs/14-recipes-cookbook.md +2 -0
  37. package/docs/15-tag-conventions.md +5 -1
  38. package/docs/16-ci-cd.md +161 -124
  39. package/docs/README.md +5 -5
  40. package/docs/advanced-screenshots.md +3 -1
  41. package/docs/api-step-definitions.md +16 -2
  42. package/docs/global-settings.md +70 -18
  43. package/docs/install-webship-js/ddev-webship-js.md +3 -0
  44. package/docs/install-webship-js.md +16 -2
  45. package/docs/step-definitions/then-i-should-see.md +14 -1
  46. package/docs/step-definitions/then-item-checkbox.md +2 -0
  47. package/docs/step-definitions/when-i-fill.md +4 -0
  48. package/docs/step-definitions/when-i-select-option-select-list.md +2 -0
  49. package/examples/a11y-legacy-widget.html +34 -0
  50. package/examples/auth-state.html +42 -0
  51. package/examples/choice-controls.html +29 -0
  52. package/examples/clock.html +33 -0
  53. package/examples/datetime-fields.html +52 -0
  54. package/examples/downloads/webship-archive.zip +0 -0
  55. package/examples/downloads/webship-notes.txt +4 -0
  56. package/examples/downloads/webship-report.csv +4 -0
  57. package/examples/downloads.html +16 -0
  58. package/examples/element-selector-hint.html +16 -0
  59. package/examples/element-viewport.html +42 -0
  60. package/examples/field-states.html +27 -0
  61. package/examples/field-types.html +98 -0
  62. package/examples/fill-in-empty.html +26 -0
  63. package/examples/fill-unreachable.html +27 -0
  64. package/examples/iframe-inner.html +20 -0
  65. package/examples/iframe-nested.html +16 -0
  66. package/examples/iframe-newsletter.html +29 -0
  67. package/examples/iframe-order.html +26 -0
  68. package/examples/iframe-outer.html +15 -0
  69. package/examples/iframe.html +21 -0
  70. package/examples/javascript-errors.html +35 -0
  71. package/examples/links.html +1 -0
  72. package/examples/metatags.html +18 -0
  73. package/examples/mouse-and-pointer.html +83 -0
  74. package/examples/multi-value-fields.html +54 -0
  75. package/examples/native-dialogs.html +8 -0
  76. package/examples/network.html +83 -0
  77. package/examples/registered-names.html +15 -0
  78. package/examples/scroll-horizontal.html +50 -0
  79. package/examples/select-by-label.html +33 -0
  80. package/examples/selectors-position.html +29 -0
  81. package/examples/settle-budget.html +21 -0
  82. package/examples/sorted-tables.html +38 -0
  83. package/examples/storage.html +57 -0
  84. package/examples/text-matching.html +48 -0
  85. package/examples/text-order.html +25 -0
  86. package/examples/touch.html +22 -0
  87. package/examples/viewport-size.html +24 -0
  88. package/examples/viewport-top.html +36 -0
  89. package/examples/wait-conditions.html +69 -0
  90. package/examples/web-first.html +99 -0
  91. package/package.json +24 -2
  92. package/playwright.config.ts +3 -1
  93. package/tests/assets/catalog.xml +19 -0
  94. package/tests/assets/feed-namespaced.xml +13 -0
  95. package/tests/assets/sitemap.xml +14 -0
  96. package/tests/assets/webship-site-expected.yaml +21 -0
  97. package/tests/assets/webship-site.schema.json +46 -0
  98. package/tests/assets/webship-site.yaml +21 -0
  99. package/tests/check-api-launch-url.js +106 -0
  100. package/tests/check-assets.js +103 -0
  101. package/tests/check-attachments.js +105 -0
  102. package/tests/check-breakpoints.js +117 -0
  103. package/tests/check-clock.js +143 -0
  104. package/tests/check-config.js +90 -0
  105. package/tests/check-context.js +215 -0
  106. package/tests/check-dry-run.js +104 -0
  107. package/tests/check-examples.js +241 -0
  108. package/tests/check-exit-report.js +141 -0
  109. package/tests/check-javascript-errors.js +105 -0
  110. package/tests/check-must-fail.js +85 -0
  111. package/tests/check-paths.js +82 -0
  112. package/tests/check-report.js +119 -0
  113. package/tests/check-scaffold.js +246 -0
  114. package/tests/check-screenshots.js +117 -0
  115. package/tests/check-settle-verbs.js +137 -0
  116. package/tests/check-time-limit.js +104 -0
  117. package/tests/check-video.js +156 -0
  118. package/tests/check-world.js +167 -0
  119. package/tests/features/a11y.feature +18 -0
  120. package/tests/features/api-base-url.feature +25 -0
  121. package/tests/features/api-form-data.feature +18 -0
  122. package/tests/features/api-json-paths.feature +24 -0
  123. package/tests/features/api-response-contains.feature +21 -0
  124. package/tests/features/api-response-header-presence.feature +17 -0
  125. package/tests/features/api-response-header.feature +17 -0
  126. package/tests/features/api-saved-placeholders.feature +37 -0
  127. package/tests/features/api-step-definitions-individual.feature +1 -1
  128. package/tests/features/api-tables.feature +40 -0
  129. package/tests/features/auth-state.feature +32 -0
  130. package/tests/features/breakpoints.feature +25 -0
  131. package/tests/features/choice-controls.feature +35 -0
  132. package/tests/features/clock.feature +27 -0
  133. package/tests/features/complete-api-testing-examples.feature +1 -1
  134. package/tests/features/cookie.feature +9 -0
  135. package/tests/features/datetime-field-lookup.feature +29 -0
  136. package/tests/features/dialog.feature +27 -0
  137. package/tests/features/element-selector-hint.feature +14 -0
  138. package/tests/features/element.feature +47 -0
  139. package/tests/features/field-state.feature +21 -0
  140. package/tests/features/field.feature +104 -0
  141. package/tests/features/file-download.feature +64 -0
  142. package/tests/features/fill-in-empty-value.feature +41 -0
  143. package/tests/features/fill-reachable.feature +13 -0
  144. package/tests/features/iframe-nested.feature +43 -0
  145. package/tests/features/iframe.feature +83 -0
  146. package/tests/features/javascript-tolerated-errors.feature +20 -0
  147. package/tests/features/javascript.feature +47 -0
  148. package/tests/features/link.feature +11 -0
  149. package/tests/features/metatag.feature +38 -0
  150. package/tests/features/modal-open.feature +13 -0
  151. package/tests/features/mouse-and-pointer.feature +86 -0
  152. package/tests/features/multi-value-field-lookup.feature +30 -0
  153. package/tests/features/network-mocking.feature +80 -0
  154. package/tests/features/registered-names.feature +14 -0
  155. package/tests/features/responsive.feature +27 -0
  156. package/tests/features/scroll-horizontal.feature +55 -0
  157. package/tests/features/select-by-label.feature +31 -0
  158. package/tests/features/selector-files.feature +14 -0
  159. package/tests/features/selectors-position.feature +41 -0
  160. package/tests/features/selectors-table-header.feature +35 -0
  161. package/tests/features/settle-budget.feature +11 -0
  162. package/tests/features/sorted-tables.feature +19 -0
  163. package/tests/features/storage-quoted-values.feature +26 -0
  164. package/tests/features/storage.feature +98 -0
  165. package/tests/features/test--then--i-see-locator.feature +13 -0
  166. package/tests/features/test--then--i-should--see-text-in-element.feature +9 -1
  167. package/tests/features/test--then--the-field-should-contain-value.feature +8 -0
  168. package/tests/features/text-matching.feature +38 -0
  169. package/tests/features/text-order.feature +14 -0
  170. package/tests/features/touch.feature +21 -0
  171. package/tests/features/video.feature +1 -0
  172. package/tests/features/viewport-top.feature +13 -0
  173. package/tests/features/wait.feature +89 -0
  174. package/tests/features/web-first.feature +100 -0
  175. package/tests/features/xml-namespaces.feature +34 -0
  176. package/tests/features/xml.feature +96 -0
  177. package/tests/features/yaml.feature +75 -0
  178. package/tests/must-fail/api-json-paths.feature +21 -0
  179. package/tests/must-fail/api-response-contains.feature +23 -0
  180. package/tests/must-fail/api-response-header-presence.feature +17 -0
  181. package/tests/must-fail/api-response-header.feature +21 -0
  182. package/tests/must-fail/api-without-base-url.feature +11 -0
  183. package/tests/must-fail/assertions.feature +96 -0
  184. package/tests/must-fail/breakpoints.feature +15 -0
  185. package/tests/must-fail/choice-controls.feature +25 -0
  186. package/tests/must-fail/clock.feature +11 -0
  187. package/tests/must-fail/datetime-field.feature +10 -0
  188. package/tests/must-fail/element-selector-hint.feature +17 -0
  189. package/tests/must-fail/field-state.feature +20 -0
  190. package/tests/must-fail/fill-field.feature +30 -0
  191. package/tests/must-fail/iframe-text.feature +17 -0
  192. package/tests/must-fail/modal-open.feature +26 -0
  193. package/tests/must-fail/multi-value-field.feature +18 -0
  194. package/tests/must-fail/registered-names.feature +25 -0
  195. package/tests/must-fail/select-list.feature +15 -0
  196. package/tests/must-fail/selector-files.feature +10 -0
  197. package/tests/must-fail/sorted-tables.feature +20 -0
  198. package/tests/must-fail/storage-before-a-page.feature +13 -0
  199. package/tests/must-fail/text-matching.feature +16 -0
  200. package/tests/must-fail/text-order.feature +15 -0
  201. package/tests/must-fail/viewport-top.feature +20 -0
  202. package/tests/must-fail/waits.feature +51 -0
  203. package/tests/must-fail/yaml-numbers.feature +48 -0
  204. package/tests/reports/README.md +2 -2
  205. package/tests/step-definitions/a11y.steps.js +36 -23
  206. package/tests/step-definitions/action.steps.js +22 -8
  207. package/tests/step-definitions/api.steps.js +349 -67
  208. package/tests/step-definitions/assertion.steps.js +327 -63
  209. package/tests/step-definitions/auth.steps.js +15 -18
  210. package/tests/step-definitions/clock.steps.js +22 -0
  211. package/tests/step-definitions/debug.steps.js +8 -0
  212. package/tests/step-definitions/dialog.steps.js +9 -2
  213. package/tests/step-definitions/element.steps.js +135 -18
  214. package/tests/step-definitions/field.steps.js +523 -80
  215. package/tests/step-definitions/file-download.steps.js +74 -10
  216. package/tests/step-definitions/form.steps.js +76 -29
  217. package/tests/step-definitions/iframe.steps.js +89 -29
  218. package/tests/step-definitions/input.steps.js +26 -7
  219. package/tests/step-definitions/javascript.steps.js +64 -22
  220. package/tests/step-definitions/modal.steps.js +79 -13
  221. package/tests/step-definitions/navigation.steps.js +14 -0
  222. package/tests/step-definitions/network.steps.js +15 -5
  223. package/tests/step-definitions/response.steps.js +6 -4
  224. package/tests/step-definitions/responsive.steps.js +26 -33
  225. package/tests/step-definitions/screenshot.steps.js +26 -9
  226. package/tests/step-definitions/scroll.steps.js +20 -0
  227. package/tests/step-definitions/selectors.steps.js +104 -51
  228. package/tests/step-definitions/storage.steps.js +41 -16
  229. package/tests/step-definitions/table.steps.js +81 -6
  230. package/tests/step-definitions/video.steps.js +52 -55
  231. package/tests/step-definitions/wait.steps.js +209 -54
  232. package/tests/step-definitions/web-first.steps.js +69 -35
  233. package/tests/step-definitions/webship.js +807 -128
  234. package/tests/step-definitions/xml.steps.js +124 -28
  235. package/tests/step-definitions/yaml.steps.js +90 -46
  236. package/.scratch/commit.txt +0 -14
  237. package/.scratch/docs.py +0 -42
  238. package/.scratch/echo-server.js +0 -8
  239. package/.scratch/echo.js +0 -35
  240. package/.scratch/echo.pid +0 -1
  241. package/.scratch/features/cookies.feature +0 -22
  242. package/.scratch/http.pid +0 -1
  243. package/.scratch/https.pid +0 -1
  244. package/.scratch/issue.md +0 -49
  245. package/.scratch/one.js +0 -2
  246. package/.scratch/one.json +0 -280
  247. package/.scratch/patch.py +0 -163
  248. package/.scratch/pr.md +0 -30
package/cucumber.js CHANGED
@@ -1,3 +1,31 @@
1
+ // A feature file, a scenario (file:line), a folder or a rerun file named on
2
+ // the command line of cucumber-js runs alone. cucumber-js 12 adds the paths
3
+ // of the command line to the `paths` of this file instead of using them
4
+ // alone, so `paths` is left empty when the command line names any: what
5
+ // cucumber-js announces for its next major version.
6
+ const OPTIONS_WITH_A_VALUE = new Set([
7
+ '-c', '--config', '-f', '--format', '--format-options', '--i18n-keywords',
8
+ '-i', '--import', '-l', '--loader', '--language', '--name', '--order',
9
+ '-p', '--profile', '--parallel', '--plugin', '--plugin-options',
10
+ '-r', '--require', '--require-module', '--retry', '--retry-tag-filter',
11
+ '--shard', '-t', '--tags', '--world-parameters',
12
+ ]);
13
+
14
+ function commandLinePaths() {
15
+ // Only when cucumber-js itself runs, not when another script reads this file.
16
+ if (!/cucumber(-js|\.js)?$/.test(String(process.argv[1] || ''))) return [];
17
+ const args = process.argv.slice(2);
18
+ const paths = [];
19
+ for (let i = 0; i < args.length; i += 1) {
20
+ if (args[i].startsWith('-')) {
21
+ if (OPTIONS_WITH_A_VALUE.has(args[i])) i += 1;
22
+ } else {
23
+ paths.push(args[i]);
24
+ }
25
+ }
26
+ return paths;
27
+ }
28
+
1
29
  module.exports = {
2
30
  default: {
3
31
  // Cucumber step timeout must exceed Playwright's default 30s so the
@@ -14,7 +42,7 @@ module.exports = {
14
42
  require: [
15
43
  'tests/step-definitions/**/*.js',
16
44
  ],
17
- paths: ['tests/features/**/*.feature'],
45
+ paths: commandLinePaths().length ? [] : ['tests/features/**/*.feature'],
18
46
  format: [
19
47
  '@cucumber/pretty-formatter',
20
48
  'json:tests/reports/cucumber_report.json',
@@ -63,9 +91,12 @@ module.exports = {
63
91
  // Load additional selectors from JSON files at scenario start.
64
92
  filesPath: './tests/selectors/', // base path for selector files
65
93
  files: [], // e.g. ['homepage-selectors.json'] or ['front-end-selectors.json', 'back-end-selectors.json']
66
- // Relative-position scroll offset (px) — WEBSHIP_SELECTORS_OFFSET
67
- offset: 60,
68
- // Viewport breakpoints — WEBSHIP_SELECTORS_BREAKPOINTS (JSON string)
94
+ // Named viewport sizes for every step and tag that names one (viewing
95
+ // the site on a … screen, set the viewport to the "…" breakpoint,
96
+ // @mobile, @desktop). Built in: xs..xxxl, mobile, tablet, desktop;
97
+ // these replace or add names. WEBSHIP_SELECTORS_BREAKPOINTS (a JSON
98
+ // object) is merged over them. Without a `desktop` here, @desktop
99
+ // opens at the breakpoint marked default: true.
69
100
  breakpoints: {
70
101
  xs: { width: 375, height: 667 }, // phone portrait
71
102
  sm: { width: 576, height: 800 }, // large phone / phablet
@@ -89,19 +120,23 @@ module.exports = {
89
120
  },
90
121
  video: {
91
122
  // Record the browser as a webm video.
92
- // 'off' (default) — no recording.
123
+ // 'off' (default) — no recording, except scenarios tagged @video.
93
124
  // 'on' — record every scenario.
94
- // 'on-failure' — record every scenario, keep only failures.
95
- // 'tag' — record only scenarios tagged @video.
125
+ // 'on-failure' — record every scenario, keep only failures (and
126
+ // the videos of @video scenarios or with a name
127
+ // reserved by "I save the current video as").
128
+ // 'tag' — the same as 'off': only scenarios tagged @video.
96
129
  // Override per scenario with tags:
97
- // @video — force recording on (independent of mode).
130
+ // @video — force recording on (in every mode).
98
131
  // @no-video — suppress recording for this scenario.
99
132
  // Override per run with env: WEBSHIP_VIDEO.
100
133
  mode: 'off', // WEBSHIP_VIDEO
101
134
  dir: './videos', // WEBSHIP_VIDEO_DIR
102
- size: { width: 1280, height: 720 }, // viewport size of the recording
103
- // Filename template tokens: {datetime} {feature_file} {feature} {scenario}
104
- // {status} {ext}. Sanitised to filesystem-safe characters.
135
+ size: { width: 1280, height: 720 }, // WEBSHIP_VIDEO_SIZE e.g. "1280x720"
136
+ // Filename template tokens: {datetime} (when the recording started)
137
+ // {feature_file} {feature} {scenario} {status} (passed, failed, … in
138
+ // lower case; "manual" for a recording stopped by a step) {ext}.
139
+ // Sanitised to filesystem-safe characters.
105
140
  filenamePattern: '{datetime}.{feature_file}.{scenario}.{status}.{ext}',
106
141
  },
107
142
  javascript: {
@@ -27,7 +27,7 @@ code. No selector jargon.
27
27
  * **Automatic smart waits** — every action waits for the page to
28
28
  settle. No `sleep` / `wait 5s` needed in the happy path.
29
29
  * **HTML report** — runs auto-generate `tests/reports/cucumber_report.html`.
30
- * **Screenshots on failure** — saved to `screenshots/` for instant
30
+ * **Screenshots on failure** — saved to `tests/screenshots/` for instant
31
31
  debugging.
32
32
 
33
33
  ## 30-second install
@@ -37,19 +37,50 @@ npm install webship-js --save-dev
37
37
  ```
38
38
 
39
39
  The post-install script copies a starter `cucumber.js`,
40
- `playwright.config.ts`, and `tests/` skeleton.
40
+ `playwright.config.ts`, and `tests/` skeleton, adds the `test` scripts to
41
+ `package.json`, and downloads Chromium into the Playwright cache. If it
42
+ reports that the browser was not installed, run:
43
+
44
+ ```bash
45
+ npx playwright install chromium
46
+ ```
47
+
48
+ When npm skips install scripts (it warns that webship-js has "install
49
+ scripts not yet covered by allowScripts", or `--ignore-scripts` is set),
50
+ nothing is copied and `npm test` answers `Error: no test specified`. Run
51
+ the same scaffold by hand, then let the script run on the next installs:
52
+
53
+ ```bash
54
+ npx init-webship-js
55
+ npm install-scripts approve webship-js
56
+ ```
57
+
58
+ The scaffold never replaces a file or a `test` script the project already
59
+ has, with two exceptions: npm's "no test specified" placeholder, and a
60
+ `test` script that runs Nightwatch (a project upgraded from webship-js
61
+ 1.x), which becomes the cucumber-js suite while the old command stays
62
+ available as `npm run test:nightwatch`. `npx init-webship-js --force`
63
+ rewrites the scaffold's files and scripts, but never
64
+ `tests/step-definitions/custom.js`, which holds the project's own steps.
65
+
66
+ Firefox and WebKit are optional: `npx playwright install firefox webkit`.
41
67
 
42
68
  ## 60-second first test
43
69
 
44
- 1. Drop your scenario into `tests/features/smoke.feature`.
45
- 2. Make sure your dev server is running on `http://localhost:8080`
46
- (or set `LAUNCH_URL` to point elsewhere).
47
- 3. Run:
70
+ The skeleton comes with `tests/features/check-homepage.feature`, which
71
+ opens the home page of your site. Run it first:
48
72
 
49
73
  ```bash
50
- npm test
74
+ LAUNCH_URL=https://your-site.example npm test
51
75
  ```
52
76
 
77
+ Without `LAUNCH_URL` the suite opens `http://localhost:8080`.
78
+
79
+ Then:
80
+
81
+ 1. Drop your scenario into `tests/features/smoke.feature`.
82
+ 2. Run `npm test` again.
83
+
53
84
  If your scenario passes, you're done. If it fails, the Cucumber output
54
85
  names the step that failed and the expected vs actual.
55
86
 
@@ -23,24 +23,32 @@ __webshipAjaxCount === 0
23
23
 
24
24
  …or when `budget` elapses, whichever comes first.
25
25
 
26
+ The probe is polled from Node (`page.evaluate` in a loop), never from a timer
27
+ inside the page. A poll that ran on the page's own `setTimeout` would be counted
28
+ in `__webshipPendingTimers` like any other timer, so the wait would see its own
29
+ next poll and never find the page quiet. `When I wait until pending timers settle`
30
+ reads the count the same way.
31
+
26
32
  ### How the budget is shared
27
33
 
28
34
  Each phase is best-effort — a phase that times out is not a failure — and each
29
- gets a **share of the budget** rather than "whatever is left":
35
+ but the last gets a **share of the budget** rather than "whatever is left":
30
36
 
31
37
  | Phase | Share of the budget |
32
38
  | --- | --- |
33
39
  | `<body>` attached | 25% |
34
40
  | `DOMContentLoaded` | 25% |
35
41
  | `networkidle` | 50% |
36
- | AJAX + pending timers + DOM quiet | 50% |
42
+ | AJAX + pending timers + DOM quiet | everything left |
37
43
 
38
- The shares add up to more than 100% on purpose: a phase that finishes early
39
- hands its unspent time to the ones after it, and no phase is ever given more
40
- than what is actually left. Capping `networkidle` matters, because on a page
41
- with analytics, a chat widget or a self-rescheduling timer it never arrives —
42
- uncapped it would eat the whole budget and starve the AJAX / pending-timer /
43
- DOM-quiet probe, which is the phase that decides the answer.
44
+ A phase that finishes early hands its unspent time to the ones after it, and
45
+ no phase is ever given more than what is actually left. Capping `networkidle`
46
+ matters, because on a page with analytics, a chat widget or a
47
+ self-rescheduling timer it never arrives — uncapped it would eat the whole
48
+ budget and starve the AJAX / pending-timer / DOM-quiet probe, which is the
49
+ phase that decides the answer. That probe comes last, so it takes the whole
50
+ rest of the budget: after a step that changes the page (1.5 seconds), a
51
+ request or a timer of a second is still waited for.
44
52
 
45
53
  `smartSettle` returns within `budget` even when nothing on the page ever
46
54
  settles, and never hands Playwright a zero timeout (Playwright reads `0` as
@@ -76,14 +84,17 @@ When I wait for the modal to disappear
76
84
  # Body + DOMContentLoaded only (cheaper than full smart settle).
77
85
  When I wait until the page is interactive
78
86
 
79
- # Polling text assertion — re-runs the matcher until the deadline.
87
+ # Polling text assertion — re-runs the matcher until the deadline. It reads the
88
+ # page as "I should see" does: letter case ignored, hidden text included.
80
89
  Then eventually I should see "Done"
81
90
  Then eventually I should see "Done" within 10 seconds
82
91
  ```
83
92
 
84
93
  ## Auto-settle after actions
85
94
 
86
- After every state-changing step (click, press, fill, submit, select, check, uncheck, choose, attach, reload, navigate), webship-js silently runs `smartSettle(page, 1500)`. Tests do not need an explicit wait between an action and its follow-up assertion in the typical case. Disable per-run with `WEBSHIP_AUTO_SETTLE=off`.
95
+ After every state-changing step, webship-js silently runs `smartSettle(page, 1500)`. Tests do not need an explicit wait between an action and its follow-up assertion in the typical case. Disable per-run with `WEBSHIP_AUTO_SETTLE=off`.
96
+
97
+ A step is state-changing when its own words — not its quoted arguments — carry one of these verbs: click, press, fill, submit, select, check, uncheck, choose, attach, upload, reload, move back / forward, go to, navigate, on the homepage, open, close, add, remove, insert, delete, save, publish, edit, update, create, enter, type, clear, reset, drag, drop, hover, tap, toggle, expand, collapse, search, send, request, flush, confirm, cancel, accept, dismiss, log in / out, sign in / out. The list covers the built-in steps and the way a project's own steps are usually worded (`When I add "Laptop" to the cart`, `When I log out`, `When I enter the 2FA code "123456"`). `Then I should see "Delete"` is no action: the verb is in the quoted text. A scroll gets no settle on purpose: it often starts a loader ("Loading more items…") that the next step checks while it shows. A project step whose words carry none of the verbs waits the same way by calling `await this.smartSettle()` itself.
87
98
 
88
99
  ## What this kills
89
100
 
@@ -25,6 +25,8 @@ Scenario: Layout assertions
25
25
  Then "main" should be visible
26
26
  ```
27
27
 
28
+ The table may start with a row that names its columns, `| name | css selector |` (or `| name | xpath selector |` for `I define xpath selectors:`): that first row is read as the header of the table and registers nothing.
29
+
28
30
  ### 3. JSON file (project-wide preset)
29
31
 
30
32
  ```js
@@ -37,6 +39,8 @@ worldParameters: {
37
39
  }
38
40
  ```
39
41
 
42
+ A file of `files` (and of `When I add selectors from "…" file`) is looked for in the `filesPath` folder first (default `./tests/selectors/`), then as written from the project root: `'auth.json'` and `'tests/selectors/auth.json'` name the same file. A file found in neither place fails the scenario with the paths tried.
43
+
40
44
  Every scenario starts with a fresh registry. Later entries with the same name override earlier ones (last wins).
41
45
 
42
46
  ## Built-in CMS / framework presets
@@ -93,3 +97,23 @@ To keep tests portable, every preset exposes the same core names. See `tests/sel
93
97
  - Modifier first (`active tab`, `danger button`, `first list item`).
94
98
  - Synonyms collapse to canonical names (`alert success` / `notification success` / `callout success` → `notice success`).
95
99
  - `data table` for HTML tables; `data list` for `ul`/`ol` collections.
100
+
101
+ ## Bare names and your own steps
102
+
103
+ The steps that take registered names without quotes (`When I click primary button`, `Then I see visible header, footer`, `Then I don't see promo banner`, `Then I see header above footer`, `Then I see search input has focus`) match any unquoted words after their verb, so that every registered name works, `sign in button` and `log in link` included. A custom step of your project that starts the same way with unquoted words matches them too: `When I click next button in tour` is ambiguous between your step and the bare-name click, and cucumber-js stops at it.
104
+
105
+ Write such a step with a quoted argument and words of its own around it (`When I click "Next" in the tour`), or start it with other words (`When I move to the next step of the tour`). Or register the element and use the built-in step: `When I add "tour next button" selector for ".tour .next" css selector`, then `When I click tour next button`. After adding a step, `npx cucumber-js --dry-run` lists every step that is ambiguous.
106
+
107
+ ## Which steps read a registered name
108
+
109
+ The registry is read by the bare-name steps above and by the modal steps. Every step that takes its argument in quotes reads it as it is written: a text (`I click "Subscribe"`, `I press "Save"`), a label, a placeholder or a name (`I fill in "Email" with "…"`), or a CSS selector (`"#dashboard" should be visible`, `the element "#hero" should be displayed`). A registered name given to one of those steps matches nothing, and its failure says so and names the step to use:
110
+
111
+ ```
112
+ ✖ Then "premium-banner" should be visible
113
+ Expected "premium-banner" to be visible.
114
+ Found: last seen: false
115
+ Page: http://localhost:8080/registered-names.html
116
+ Hint: "premium-banner" is a name of the selector registry (.promo-banner), but this step does not read the registry. Use: I see visible premium-banner, or: ".promo-banner" should be visible
117
+ ```
118
+
119
+ The hint is added to the failures of the click and press steps, the fill steps, the web-first steps (`"…" should be visible`, `… should have text`, …) and the element steps (`I click on the element "…"`, `I scroll to the element "…"`, `the element "…" should be at the top of the viewport`, …).
@@ -29,15 +29,15 @@ This is a topical reference. For per-step examples, see the JSDoc comment above
29
29
 
30
30
  | Step | Notes |
31
31
  | --- | --- |
32
- | `When I fill in "Label" with "value"` | Resolves by label / placeholder / name |
32
+ | `When I fill in "Label" with "value"` | Resolves by label / placeholder / name. `with ""` empties the field, in every fill form. A hidden, disabled or read-only field fails within 5 s, saying which |
33
33
  | `When I fill in "value" for "Label"` | Reverse phrasing |
34
34
  | `When I fill in "value" for "selector" by attr` | By attribute |
35
35
  | `When I fill in the following:` (table) | Bulk fill |
36
- | `When I select "Option" from "Label"` | `<select>` |
36
+ | `When I select "Option" from "Label"` | `<select>` by the exact text of its label, its name, its id, or a CSS selector (`#`, `.`, `[`); the option by its text or value |
37
37
  | `When I additionally select "Option" from "Label"` | Multi-select |
38
- | `When I check the checkbox "#agree"` | |
39
- | `When I uncheck the checkbox "#agree"` | |
40
- | `When I choose the radio button "#radio"` | |
38
+ | `When I check the checkbox "#agree"` | By CSS selector, label, name, id or value |
39
+ | `When I uncheck the checkbox "#agree"` | By CSS selector, label, name, id or value |
40
+ | `When I choose the radio button "#radio"` | By CSS selector, label, id or value |
41
41
 
42
42
  ## Waits — see [BBR](02-bbr-smart-waits.md)
43
43
 
@@ -64,6 +64,16 @@ I wait for the modal to appear/disappear # Modal edge
64
64
  eventually I should see "..." # Polling text assertion
65
65
  ```
66
66
 
67
+ ## Page text
68
+
69
+ | Step | Notes |
70
+ | --- | --- |
71
+ | `Then I should see "text"` | Waits up to 5 s for the text to come |
72
+ | `Then I should not see "text"` | Waits up to 5 s for the text to go |
73
+ | `Then eventually I should see "text" [within N seconds]` | Waits up to 10 s, or N |
74
+
75
+ The three read the page the same way: letter case ignored, white space collapsed, the text of hidden elements included, the text of `<script>` and `<style>` left out. For the text a visitor can see, with its letter case, use `I wait for the text "..." to appear` / `to disappear`. See [Then I should see](step-definitions/then-i-should-see.md).
76
+
67
77
  ## Modal
68
78
 
69
79
  | Step | |
@@ -72,9 +82,9 @@ eventually I should see "..." # Polling text assertion
72
82
  | `Then I should not see the modal` | |
73
83
  | `Then I should see "text" in the modal` | |
74
84
  | `Then the modal should contain "text"` | |
75
- | `When I click "OK" in the modal` | |
76
- | `When I click on "#sel" in the modal` | |
77
- | `When I close the modal` | |
85
+ | `When I click "OK" in the modal` | Waits up to 5 s for a modal to be open, else fails with "No modal is open"; a button the open modal lacks fails, listing the ones it has |
86
+ | `When I click on "#sel" in the modal` | The selector inside the open modal only; same 5 s wait for an open modal |
87
+ | `When I close the modal` | Close button, else Escape; same 5 s wait for an open modal |
78
88
 
79
89
  ## Web-first assertions (auto-retry)
80
90
 
@@ -101,9 +111,12 @@ See `cookie.steps.js`, `response.steps.js`, `metatag.steps.js`.
101
111
  the table "selector" should have N rows
102
112
  the table "selector" should have N columns
103
113
  the table "selector" should not be empty
114
+ the table "selector" should be sorted by "Column" in "ascending|descending" order
104
115
  I should see "Text" in the "RowMatch" row
105
116
  ```
106
117
 
118
+ The sorted step compares the cells of the column the way a reader orders them: as numbers when every cell reads as a number (`$9.99`, `1,299`, `12 %`), else as dates when every cell reads as a date, else as text with letter case ignored and the numbers inside the text in number order ("Item 2" before "Item 10"). Equal cells may come in any order.
119
+
107
120
  ## Iframes / file download / REST / XML / keyboard
108
121
 
109
122
  See per-topic files in `tests/step-definitions/`. Each file has JSDoc above every step with all pronoun and tense variants.
@@ -227,7 +240,9 @@ Settings (`worldParameters.javascript`):
227
240
  | `beforeScenario` | `WEBSHIP_JS_ERROR_BEFORE` | `false` | Snapshot pre-existing errors at scenario start |
228
241
  | `afterScenario` | `WEBSHIP_JS_ERROR_AFTER` | `true` | Report at scenario end |
229
242
 
230
- The explicit step `Then there should be no JavaScript errors` always asserts (independent of `mode`) and suppresses the auto-report so a single error is not announced twice.
243
+ The explicit step `Then there should be no JavaScript errors` counts errors only — uncaught errors and `console.error`, not the warnings when `warning` is a captured level — always asserts (independent of `mode`) and leaves the errors out of the auto-report so a single error is not announced twice; `Then there should be no JavaScript warnings` does the same for the warnings. What a check did not read is still reported at the end of the scenario.
244
+
245
+ `Then JavaScript errors should not match "…"` handles the errors it read in the same way: a page with noise it tolerates does not fail the scenario at its end in `fail` mode, only an error that matches the pattern fails it.
231
246
 
232
247
  ## Video recording
233
248
 
@@ -248,10 +263,10 @@ Mode semantics:
248
263
 
249
264
  | Mode | Behaviour |
250
265
  | --- | --- |
251
- | `off` (default) | No recording. |
266
+ | `off` (default) | No recording, except the scenarios tagged `@video`. |
252
267
  | `on` | Every scenario produces a `webm`. |
253
- | `on-failure` | Every scenario records; only failures are kept on disk. |
254
- | `tag` | Only scenarios tagged `@video` record. |
268
+ | `on-failure` | Every scenario records; only failures are kept on disk, with the `@video` scenarios and the videos whose name `I save the current video as` reserved. |
269
+ | `tag` | The same as `off`: only scenarios tagged `@video` record. |
255
270
 
256
271
  Settings (`worldParameters.video`):
257
272
 
@@ -259,10 +274,10 @@ Settings (`worldParameters.video`):
259
274
  | --- | --- | --- | --- |
260
275
  | `mode` | `WEBSHIP_VIDEO` | `off` | Activation mode. |
261
276
  | `dir` | `WEBSHIP_VIDEO_DIR` | `./videos` | Output directory (created automatically). |
262
- | `size` | _none_ | `{ width: 1280, height: 720 }` | Recording resolution. |
263
- | `filenamePattern` | _none_ | `{datetime}.{feature_file}.{scenario}.{status}.{ext}` | Per-scenario filename. Tokens: `{datetime} {feature_file} {feature} {scenario} {status} {ext}`. |
277
+ | `size` | `WEBSHIP_VIDEO_SIZE` (`1280x720`) | `{ width: 1280, height: 720 }` | Recording resolution. |
278
+ | `filenamePattern` | _none_ | `{datetime}.{feature_file}.{scenario}.{status}.{ext}` | Per-scenario filename. Tokens: `{datetime}` (when the recording started) `{feature_file} {feature} {scenario} {status}` (`passed`, `failed`, … in lower case; `manual` for a recording `stop video recording` ended) `{ext}`. |
264
279
 
265
- The `start` / `stop` mid-scenario steps close + reopen the browser context (Playwright records at context creation only). Page state is lost across the boundary — call `start` BEFORE any navigation. `videos/` is gitignored.
280
+ `print video path` prints the path the video is saved under when the scenario ends (`<status>` stands for the result still to come). `start video recording` on a scenario that already records changes nothing. The `start` / `stop` mid-scenario steps open a new browser context (Playwright records at context creation only). The cookies and local storage, the viewport of an `@mobile` / `@desktop` tag, the smart waits, JavaScript-error capture and a running request log go on with it; the page itself starts blank — call `start` BEFORE any navigation, and open the page again after `stop`. `videos/` is gitignored.
266
281
 
267
282
  ## Date tokens
268
283
 
@@ -343,9 +358,11 @@ This index lists every public step grouped by source file, with one Gherkin exam
343
358
  - *^(?:the JSON response should have property|the API response should contain property) "([^"]*)"$* · Example: `Then the JSON response should have property "id"`
344
359
  - *^(?:the JSON response should not have property|the API response should not contain property) "([^"]*)"$* · Example: `Then the JSON response should not have property "password"`
345
360
  - *^(?:the response should be valid JSON|the API response should be valid JSON)$* · Example: `Then the response should be valid JSON`
346
- - *^(?:the response header|the header) "([^"]*)" should (?:be|contain) "([^"]*)"$* · Example: `Then the response header "Content-Type" should be "application/json"`
361
+ - *^(?:the response header|the header) "([^"]*)" should (be|contain) "([^"]*)"$* · Example: `Then the response header "Content-Type" should be "application/json; charset=utf-8"`
347
362
  - *^print API response$* · Example: `Then print API response`
363
+ - *^(?:the )?API response should( not)? contain the header "([^"]*)"$* · Example: `Then the API response should contain the header "ETag"`
348
364
  - *^(?:I|we) set placeholder "([^"]*)" to "([^"]*)"$* · Example: `Given I set placeholder "{{userId}}" to "123"`
365
+ - *^(I |we )*save the JSON property "([^"]*)" as placeholder "([^"]*)"$* · Example: `When I save the JSON property "token" as placeholder "{{token}}"`
349
366
 
350
367
  ### assertion.steps.js
351
368
 
@@ -415,6 +432,7 @@ This index lists every public step grouped by source file, with one Gherkin exam
415
432
 
416
433
  - *the element {string} should appear after the element {string}* · Example: `Then the element "#footer" should appear after the element "#main"`
417
434
  - *the text {string} should appear after the text {string}* · Example: `Then the text "Sign in" should appear after the text "Welcome"`
435
+ - *the text {string} should appear after the text {string} in the {string} element* · Example: `Then the text "Products" should appear after the text "Home" in the "nav.breadcrumb" element`
418
436
  - *the element {string} with the attribute {string} and the value {string} should exist* · Example: `Then the element "a" with the attribute "href" and the value "/about" should exist`
419
437
  - *the element {string} with the attribute {string} and the value containing {string} should exist* · Example: `Then the element "a" with the attribute "href" and the value containing "/about" should exist`
420
438
  - *the element {string} with the attribute {string} and the value {string} should not exist* · Example: `Then the element "a" with the attribute "href" and the value "/admin" should not exist`
@@ -439,10 +457,10 @@ This index lists every public step grouped by source file, with one Gherkin exam
439
457
  - *the field {string} should not be empty* · Example: `Then the field "username" should not be empty`
440
458
  - *the field {string} should exist* · Example: `Then the field "username" should exist`
441
459
  - *the field {string} should not exist* · Example: `Then the field "missing-field" should not exist`
442
- - *the field {string} should have {string} state* · Example: `Then the field "username" should have "enabled" state`
460
+ - *the field {string} should have {string} state* · Example: `Then the field "username" should have "enabled" state` · States: `enabled`, `disabled`, `editable`, `read-only` (or `readonly`); any other word fails the step
443
461
  - *the field {string} should be required* · Example: `Then the field "username" should be required`
444
462
  - *the field {string} should not be required* · Example: `Then the field "bio" should not be required`
445
- - *^(I |we )*fill in the multi-value field "([^"]*)" with the following values:$* · Example: `When I fill in the multi-value field "tags" with the following values:`
463
+ - *^(I |we )*fill in the multi-value field "([^"]*)" with the following values:$* · Example: `When I fill in the multi-value field "tags" with the following values:` · The field: the name of its inputs (`tags[]`, `tags[0]`, `tags[0][value]`), the legend of its fieldset, or its label; fewer inputs than values fails before anything is filled
446
464
  - *^(I |we )*fill in the color field "([^"]*)" with the value "([^"]*)"$* · Example: `When I fill in the color field "favorite" with the value "#ff0000"`
447
465
  - *the color field {string} should have the value {string}* · Example: `Then the color field "favorite" should have the value "#ff0000"`
448
466
  - *^(I |we )*fill in the WYSIWYG field "([^"]*)" with the "([^"]*)"$* · Example: `When I fill in the WYSIWYG field "body" with the "Hello world"`
@@ -462,6 +480,7 @@ This index lists every public step grouped by source file, with one Gherkin exam
462
480
  - *^(I |we )*fill in the time part of the datetime field "([^"]*)" with "([^"]*)"$* · Example: `When I fill in the time part of the datetime field "Start" with "10:00"`
463
481
  - *^(I |we )*fill in the start datetime field "([^"]*)" with date "([^"]*)" and time "([^"]*)"$* · Example: `When I fill in the start datetime field "Event" with date "2026-05-08" and time "10:00"`
464
482
  - *^(I |we )*fill in the end datetime field "([^"]*)" with date "([^"]*)" and time "([^"]*)"$* · Example: `When I fill in the end datetime field "Event" with date "2026-05-09" and time "18:00"`
483
+ - The datetime steps name a field by the exact text of its label or of the legend of its fieldset (white space and letter case aside) and fill only its own inputs: the one inside the label, the one the label is for, or the ones that follow the label before the next field; an input whose name or aria-label contains the text is found last. A field with no such input fails the step and fills nothing.
465
484
 
466
485
  ### file-download.steps.js
467
486
 
@@ -502,6 +521,7 @@ This index lists every public step grouped by source file, with one Gherkin exam
502
521
  - *^(I |we )*fill in "([^"]*)" with "([^"]*)" inside the iframe$* · Example: `When I fill in "card_number" with "4242 4242 4242 4242" inside the iframe`
503
522
  - *^I should see "([^"]*)" inside the iframe$* · Example: `Then I should see "Payment received" inside the iframe`
504
523
  - *^I should not see "([^"]*)" inside the iframe$* · Example: `Then I should not see "Error" inside the iframe`
524
+ - The iframe steps act in the iframe the scenario switched to last; while an iframe is active, a switch looks for the iframe inside it first, then in the page (nested iframes). `by attr inside the iframe` tries the attributes `I click "…" by attr` tries; the frame fill finds a field by label, placeholder, name or id; `I should (not) see "…" inside the iframe` reads the iframe as `I should (not) see` reads the page and waits up to 5 seconds.
505
525
 
506
526
  ### input.steps.js
507
527
 
@@ -513,7 +533,7 @@ This index lists every public step grouped by source file, with one Gherkin exam
513
533
  - *^(I |we )*click on "([^"]*)" while holding "([^"]*)"$* · Example: `When I click on "#row-1" while holding "Shift"`
514
534
  - *^(I |we )*drag "([^"]*)" to "([^"]*)"$* · Example: `When I drag "#card-1" to "#column-done"`
515
535
  - *^(I |we )*set the viewport size to (\d+)x(\d+)$* · Example: `When I set the viewport size to 1280x720`
516
- - *^(I |we )*tap on "([^"]*)"$* · Example: `When I tap on "#cta"`
536
+ - *^(I |we )*tap on "([^"]*)"$* · Example: `When I tap on "#cta"` — a real tap in a scenario tagged `@touch`; without touch, a click (and a note)
517
537
 
518
538
  ### javascript.steps.js
519
539
 
@@ -671,16 +691,20 @@ This index lists every public step grouped by source file, with one Gherkin exam
671
691
 
672
692
  ### storage.steps.js
673
693
 
674
- - *^(?:the cookie|cookie) "([^"]*)" is set to "([^"]*)"$* · Example: `Given the cookie "session" is set to "abc123"`
675
- - *^the cookie "([^"]*)" is removed$* · Example: `Given the cookie "session" is removed`
694
+ - *^(?:the cookie|cookie) "((?:[^"\\]|\\.)*)" is set to "((?:[^"\\]|\\.)*)"$* · Example: `Given the cookie "session" is set to "abc123"`
695
+ - *^the cookie "((?:[^"\\]|\\.)*)" is removed$* · Example: `Given the cookie "session" is removed`
676
696
  - *^all cookies are cleared$* · Example: `Given all cookies are cleared`
677
- - *^(?:the )?local storage "([^"]*)" is set to "([^"]*)"$* · Example: `Given the local storage "user" is set to "Alice"`
678
- - *^(?:the )?local storage "([^"]*)" is removed$* · Example: `Given the local storage "user" is removed`
697
+ - *^(?:the )?local storage "((?:[^"\\]|\\.)*)" is set to "((?:[^"\\]|\\.)*)"$* · Example: `Given the local storage "user" is set to "Alice"`
698
+ - *^(?:the )?local storage "((?:[^"\\]|\\.)*)" is removed$* · Example: `Given the local storage "user" is removed`
679
699
  - *^local storage is cleared$* · Example: `Given local storage is cleared`
680
- - *^(?:the )?session storage "([^"]*)" is set to "([^"]*)"$* · Example: `Given the session storage "checkout step" is set to "2"`
681
- - *^(?:the )?session storage "([^"]*)" is removed$* · Example: `Given the session storage "checkout step" is removed`
700
+ - *^(?:the )?session storage "((?:[^"\\]|\\.)*)" is set to "((?:[^"\\]|\\.)*)"$* · Example: `Given the session storage "checkout step" is set to "2"`
701
+ - *^(?:the )?session storage "((?:[^"\\]|\\.)*)" is removed$* · Example: `Given the session storage "checkout step" is removed`
682
702
  - *^session storage is cleared$* · Example: `Given session storage is cleared`
683
703
 
704
+ A key or a value may hold a double quote written `\"`, as in a JSON value: `Given the local storage "prefs" is set to "{\"theme\":\"dark\"}"`.
705
+
706
+ Local and session storage belong to the site of the page, so their steps need a page of the site first: before the first `Given I am on "…"` the page is blank, and the step fails with a hint to open one. A cookie can be set before any page.
707
+
684
708
  ### table.steps.js
685
709
 
686
710
  - *the table {string} should have {int} row(s)* · Example: `Then the table "#users" should have 5 rows`
@@ -705,8 +729,8 @@ This index lists every public step grouped by source file, with one Gherkin exam
705
729
  - *^(I |we )*wait for (\d+) seconds? for AJAX to finish$* · Example: `When I wait for 1 second for AJAX to finish`
706
730
  - *^(I |we )*wait (\d+)( second| seconds|s)?$* · Example: `When I wait 1 second`
707
731
  - *^(I |we )*wait max of (\d+)( second| seconds|s)?$* · Example: `When I wait max of 1 second`
708
- - *^(I |we )*wait (\d+)( minute| minutes|m)?$* · Example: `When I wait 1 minute`
709
- - *^(I |we )*wait max of (\d+)( minute| minutes|m)?$* · Example: `When I wait max of 1 minute`
732
+ - *^(I |we )*wait (\d+)( minute| minutes|m)$* · Example: `When I wait 1 minute`
733
+ - *^(I |we )*wait max of (\d+)( minute| minutes|m)$* · Example: `When I wait max of 1 minute`
710
734
  - *^(I |we )*wait until( the)* page( is)* loaded*$* · Example: `When I wait until the page is loaded`
711
735
  - *^(I |we )*wait for AJAX to finish$* · Example: `When I wait for AJAX to finish`
712
736
  - *^(I |we )*wait for( the)* modal( dialog)* to (appear|disappear)$* · Example: `When I wait for the modal to appear`
@@ -763,6 +787,8 @@ This index lists every public step grouped by source file, with one Gherkin exam
763
787
 
764
788
  ### yaml.steps.js
765
789
 
790
+ The numeric steps (greater than, less than, between) compare a YAML number only: a quoted `"3"`, `true` or `null` fails with its type, where `Number()` would have read 3, 1 or 0.
791
+
766
792
  - *the YAML response content from the file {string}* · Example: `Given the YAML response content from the file "config.yml"`
767
793
  - *the YAML response content is the following:* · Example: `Given the YAML response content is the following:`
768
794
  - *the active YAML document is {int}* · Example: `Given the active YAML document is 1`
@@ -11,6 +11,8 @@ Then "#dashboard" should be visible
11
11
  Then "#dashboard" should be visible within 12 seconds
12
12
  ```
13
13
 
14
+ A `within N seconds` longer than the step timeout (45 seconds, `WEBSHIP_STEP_TIMEOUT`) is kept: the step waits the N seconds it was given, as `I wait 2 minutes` and `eventually I should see "…" within 90 seconds` do, and fails with its own message, not with "function timed out". Such a step bounds itself at its length plus 15 seconds, so a page that stopped answering cannot hang the run.
15
+
14
16
  ## State matchers
15
17
 
16
18
  ```gherkin
@@ -37,6 +39,8 @@ Then "<sel>" should be in the viewport
37
39
  Then "<sel>" should not be in the viewport within 3 seconds
38
40
  ```
39
41
 
42
+ `the element "<sel>" should be at the top of the viewport` passes when the top of the element is between 0 and 100 pixels from the top of the viewport. It looks again for up to 5 seconds, so an element still on its way after a smooth scroll gets there, and its failure gives the measured top.
43
+
40
44
  ## Count
41
45
 
42
46
  ```gherkin
@@ -54,6 +58,8 @@ Then "<sel>" should have value "alice@example.com"
54
58
 
55
59
  `should have text` is the exact match: the element's text, trimmed. `should contain text` collapses every run of whitespace to one space, on the element's text and on the expected text, before it looks for the substring, so a line the markup wraps still matches.
56
60
 
61
+ For a text anywhere on the page, `I should see "text"` and `I should not see "text"` wait up to 5 seconds and `eventually I should see "text" within N seconds` longer. They ignore letter case and count the text of hidden elements, unlike `should have text` and `should contain text`, which match the letter case of the one element they read. See [Then I should see](step-definitions/then-i-should-see.md).
62
+
57
63
  ## Attributes / classes
58
64
 
59
65
  ```gherkin
@@ -41,7 +41,7 @@ Feature: Admin dashboard
41
41
  And "<#user-list>" should have a count of 5 within 5 seconds
42
42
  ```
43
43
 
44
- `I restore the auth state from "..."` swaps the current browser context for a fresh one with the saved cookies/localStorage. The tracker init script is reinstalled automatically so smart waits keep working.
44
+ `I restore the auth state from "..."` swaps the current browser context for a fresh one with the saved cookies/localStorage, opened the same way as the first one of the scenario: the smart-wait init script, the viewport of an `@mobile` / `@desktop` tag, video recording while it is on, JavaScript-error capture, the response tracker and a running request log all go on with the new page. The new page starts blank, so open the page you need next. Routes stubbed before the step (`the URL "…" returns …`) belonged to the closed context: stub them after it.
45
45
 
46
46
  ## Clearing auth
47
47
 
@@ -45,13 +45,32 @@ Scenario: "5 minutes ago" updates as time passes
45
45
 
46
46
  ```gherkin
47
47
  Scenario: Idle warning fires at 14 minutes
48
- Given the system time is "2026-05-08T10:00:00Z"
49
- And I restore the auth state from "tests/auth/admin.json"
48
+ Given I restore the auth state from "tests/auth/admin.json"
49
+ And the system time is "2026-05-08T10:00:00Z"
50
50
  And I am on "/dashboard"
51
51
  When I advance the clock by 14 minutes
52
52
  Then "<#session-warning>" should be visible
53
53
  ```
54
54
 
55
+ Restore the auth state first: restoring it opens a new browser context, and the clock belongs to the context it replaced. The same goes for starting or stopping a video recording.
56
+
57
+ ## Smart waits under a fake clock
58
+
59
+ The smart waits keep real time: the settle after a step does not count the
60
+ clock's timers (they belong to the clock, not to the page's work) and
61
+ measures the DOM-quiet window on the real clock, so a navigation or a press
62
+ settles as soon as the page is quiet, not after its whole budget.
63
+
64
+ `When I wait until pending timers settle` cannot see the timers of a page
65
+ under a fake clock — they run only when the clock moves — so it fails at
66
+ once and asks you to advance the clock instead.
67
+
68
+ The clock steps move the clock that `Given the system time is "…"`
69
+ installed. Without it, Playwright installs one on the first clock step, at
70
+ the current time: the timers the page set before that step keep running on
71
+ real time and do not move with the clock. Webship-js prints a note (and
72
+ attaches it to the report) when that happens.
73
+
55
74
  ## Caveats
56
75
 
57
76
  - `requestAnimationFrame` and `MutationObserver` are not on the fake clock. Animations driven by `rAF` keep playing in real time.