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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { friendly } = require('./webship');
3
+ const { friendly, failure, registeredNameHint } = require('./webship');
4
4
 
5
5
  // Web-first assertion steps — each matcher polls the live page until the
6
6
  // condition holds or the per-step timeout elapses. The assertion IS the
@@ -11,6 +11,7 @@ const { friendly } = require('./webship');
11
11
 
12
12
  const { Then, When } = require('@cucumber/cucumber');
13
13
  const assert = require('assert');
14
+ const { OWN_LENGTH, withinTimeLimit } = require('./wait.steps');
14
15
 
15
16
  function parseTimeout(secondsStr) {
16
17
  const n = secondsStr ? parseInt(secondsStr, 10) : 0;
@@ -25,20 +26,41 @@ function normalizeText(value) {
25
26
  }
26
27
 
27
28
  // Poll fn() until it returns truthy, or timeout. fn() returns a value;
28
- // `predicate` decides pass/fail. Returns the last value seen.
29
- async function poll(fn, predicate, timeout, message) {
30
- const deadline = Date.now() + timeout;
31
- let last;
32
- while (Date.now() < deadline) {
33
- try {
34
- last = await fn();
35
- if (predicate(last)) return last;
36
- } catch (e) {
37
- last = e;
29
+ // `predicate` decides pass/fail. Returns the last value seen. The matchers
30
+ // that call it take OWN_LENGTH: "within 60 seconds" runs past the step
31
+ // timeout, bounded by withinTimeLimit. `context.hint`, when the step was given
32
+ // a name of the selector registry, goes into the failure with the page.
33
+ async function poll(fn, predicate, timeout, message, context) {
34
+ return withinTimeLimit(timeout, `The check "${message}"`, async () => {
35
+ const deadline = Date.now() + timeout;
36
+ let last;
37
+ while (Date.now() < deadline) {
38
+ try {
39
+ last = await fn();
40
+ if (predicate(last)) return last;
41
+ } catch (e) {
42
+ last = e;
43
+ }
44
+ await new Promise((r) => setTimeout(r, 100));
38
45
  }
39
- await new Promise((r) => setTimeout(r, 100));
40
- }
41
- throw friendly(`${message} (last seen: ${typeof last === 'object' ? JSON.stringify(last) : String(last)})`);
46
+ const seen = typeof last === 'object' ? JSON.stringify(last) : String(last);
47
+ if (context && context.hint) {
48
+ throw failure(context.page, `${message}.`, { found: `last seen: ${seen}`, hint: context.hint });
49
+ }
50
+ throw friendly(`${message} (last seen: ${seen})`);
51
+ });
52
+ }
53
+
54
+ // The " within N seconds" a step was given, to repeat it in a hint.
55
+ function within(sec) {
56
+ return sec ? ` within ${sec} seconds` : '';
57
+ }
58
+
59
+ // The failure context of a web-first step given a name of the selector
60
+ // registry: the same step with the selector, and the bare-name step that
61
+ // reads the registry when there is one.
62
+ function registryContext(world, selector, sameStep, bare) {
63
+ return { page: world.page, hint: registeredNameHint(world, selector, { bare, withSelector: sameStep }) };
42
64
  }
43
65
 
44
66
  async function checkState(locator, state) {
@@ -69,13 +91,15 @@ async function checkState(locator, state) {
69
91
  * Example #5: Then "input#email" should be editable
70
92
  *
71
93
  */
72
- Then(/^"([^"]*)" should be (visible|hidden|attached|focused|enabled|disabled|editable)(?: within (\d+) seconds?)?$/, async function (selector, state, sec) {
94
+ Then(/^"([^"]*)" should be (visible|hidden|attached|focused|enabled|disabled|editable)(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, state, sec) {
73
95
  const loc = this.page.locator(selector);
74
96
  await poll(
75
97
  () => checkState(loc, state),
76
98
  (v) => v === true,
77
99
  parseTimeout(sec),
78
- `Expected "${selector}" to be ${state}`
100
+ `Expected "${selector}" to be ${state}`,
101
+ registryContext(this, selector, (s) => `"${s}" should be ${state}${within(sec)}`,
102
+ { visible: 'I see visible {name}', hidden: "I don't see {name}", focused: 'I see {name} has focus' }[state])
79
103
  );
80
104
  });
81
105
 
@@ -89,13 +113,15 @@ Then(/^"([^"]*)" should be (visible|hidden|attached|focused|enabled|disabled|edi
89
113
  * Example #5: Then "[data-testid=password]" should not be focused
90
114
  *
91
115
  */
92
- Then(/^"([^"]*)" should not be (visible|hidden|attached|focused|enabled|disabled|editable)(?: within (\d+) seconds?)?$/, async function (selector, state, sec) {
116
+ Then(/^"([^"]*)" should not be (visible|hidden|attached|focused|enabled|disabled|editable)(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, state, sec) {
93
117
  const loc = this.page.locator(selector);
94
118
  await poll(
95
119
  () => checkState(loc, state),
96
120
  (v) => v === false,
97
121
  parseTimeout(sec),
98
- `Expected "${selector}" to not be ${state}`
122
+ `Expected "${selector}" to not be ${state}`,
123
+ registryContext(this, selector, (s) => `"${s}" should not be ${state}${within(sec)}`,
124
+ { visible: "I don't see {name}", hidden: 'I see visible {name}' }[state])
99
125
  );
100
126
  });
101
127
 
@@ -110,7 +136,7 @@ Then(/^"([^"]*)" should not be (visible|hidden|attached|focused|enabled|disabled
110
136
  * Example #5: Then ".banner" should be in the viewport
111
137
  *
112
138
  */
113
- Then(/^"([^"]*)" should be in the viewport(?: within (\d+) seconds?)?$/, async function (selector, sec) {
139
+ Then(/^"([^"]*)" should be in the viewport(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, sec) {
114
140
  const loc = this.page.locator(selector).first();
115
141
  await poll(
116
142
  async () => loc.evaluate((el) => {
@@ -120,7 +146,8 @@ Then(/^"([^"]*)" should be in the viewport(?: within (\d+) seconds?)?$/, async f
120
146
  }),
121
147
  (v) => v === true,
122
148
  parseTimeout(sec),
123
- `Expected "${selector}" to be in viewport`
149
+ `Expected "${selector}" to be in viewport`,
150
+ registryContext(this, selector, (s) => `"${s}" should be in the viewport${within(sec)}`)
124
151
  );
125
152
  });
126
153
 
@@ -135,7 +162,7 @@ Then(/^"([^"]*)" should be in the viewport(?: within (\d+) seconds?)?$/, async f
135
162
  * Then "#footer" should not be in the viewport
136
163
  *
137
164
  */
138
- Then(/^"([^"]*)" should not be in the viewport(?: within (\d+) seconds?)?$/, async function (selector, sec) {
165
+ Then(/^"([^"]*)" should not be in the viewport(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, sec) {
139
166
  const loc = this.page.locator(selector).first();
140
167
  await poll(
141
168
  async () => loc.evaluate((el) => {
@@ -145,7 +172,8 @@ Then(/^"([^"]*)" should not be in the viewport(?: within (\d+) seconds?)?$/, asy
145
172
  }).catch(() => false),
146
173
  (v) => v === false,
147
174
  parseTimeout(sec),
148
- `Expected "${selector}" to not be in viewport`
175
+ `Expected "${selector}" to not be in viewport`,
176
+ registryContext(this, selector, (s) => `"${s}" should not be in the viewport${within(sec)}`)
149
177
  );
150
178
  });
151
179
 
@@ -159,14 +187,15 @@ Then(/^"([^"]*)" should not be in the viewport(?: within (\d+) seconds?)?$/, asy
159
187
  * Example #5: Then ".feed-item" should have a count of 25 within 10 seconds
160
188
  *
161
189
  */
162
- Then(/^"([^"]*)" should have a count of (\d+)(?: within (\d+) seconds?)?$/, async function (selector, count, sec) {
190
+ Then(/^"([^"]*)" should have a count of (\d+)(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, count, sec) {
163
191
  const expected = parseInt(count, 10);
164
192
  const loc = this.page.locator(selector);
165
193
  await poll(
166
194
  () => loc.count(),
167
195
  (v) => v === expected,
168
196
  parseTimeout(sec),
169
- `Expected "${selector}" count to be ${expected}`
197
+ `Expected "${selector}" count to be ${expected}`,
198
+ registryContext(this, selector, (s) => `"${s}" should have a count of ${expected}${within(sec)}`)
170
199
  );
171
200
  });
172
201
 
@@ -180,13 +209,14 @@ Then(/^"([^"]*)" should have a count of (\d+)(?: within (\d+) seconds?)?$/, asyn
180
209
  * Example #5: Then ".alert" should have text "Saved"
181
210
  *
182
211
  */
183
- Then(/^"([^"]*)" should have text "([^"]*)"(?: within (\d+) seconds?)?$/, async function (selector, text, sec) {
212
+ Then(/^"([^"]*)" should have text "([^"]*)"(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, text, sec) {
184
213
  const loc = this.page.locator(selector).first();
185
214
  await poll(
186
215
  () => loc.textContent(),
187
216
  (v) => (v || '').trim() === text,
188
217
  parseTimeout(sec),
189
- `Expected "${selector}" text to be "${text}"`
218
+ `Expected "${selector}" text to be "${text}"`,
219
+ registryContext(this, selector, (s) => `"${s}" should have text "${text}"${within(sec)}`)
190
220
  );
191
221
  });
192
222
 
@@ -203,14 +233,15 @@ Then(/^"([^"]*)" should have text "([^"]*)"(?: within (\d+) seconds?)?$/, async
203
233
  * Example #5: Then ".alert" should contain text "Saved"
204
234
  *
205
235
  */
206
- Then(/^"([^"]*)" should contain text "([^"]*)"(?: within (\d+) seconds?)?$/, async function (selector, text, sec) {
236
+ Then(/^"([^"]*)" should contain text "([^"]*)"(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, text, sec) {
207
237
  const loc = this.page.locator(selector).first();
208
238
  const expected = normalizeText(text);
209
239
  await poll(
210
240
  async () => normalizeText(await loc.textContent()),
211
241
  (v) => v.includes(expected),
212
242
  parseTimeout(sec),
213
- `Expected "${selector}" to contain text "${text}"`
243
+ `Expected "${selector}" to contain text "${text}"`,
244
+ registryContext(this, selector, (s) => `"${s}" should contain text "${text}"${within(sec)}`)
214
245
  );
215
246
  });
216
247
 
@@ -224,13 +255,14 @@ Then(/^"([^"]*)" should contain text "([^"]*)"(?: within (\d+) seconds?)?$/, asy
224
255
  * Example #5: Then "select#country" should have value "JO"
225
256
  *
226
257
  */
227
- Then(/^"([^"]*)" should have value "([^"]*)"(?: within (\d+) seconds?)?$/, async function (selector, value, sec) {
258
+ Then(/^"([^"]*)" should have value "([^"]*)"(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, value, sec) {
228
259
  const loc = this.page.locator(selector).first();
229
260
  await poll(
230
261
  () => loc.inputValue(),
231
262
  (v) => v === value,
232
263
  parseTimeout(sec),
233
- `Expected "${selector}" value to be "${value}"`
264
+ `Expected "${selector}" value to be "${value}"`,
265
+ registryContext(this, selector, (s) => `"${s}" should have value "${value}"${within(sec)}`)
234
266
  );
235
267
  });
236
268
 
@@ -244,13 +276,14 @@ Then(/^"([^"]*)" should have value "([^"]*)"(?: within (\d+) seconds?)?$/, async
244
276
  * Example #5: Then "input#email" should have attribute "type" with value "email"
245
277
  *
246
278
  */
247
- Then(/^"([^"]*)" should have attribute "([^"]*)" with value "([^"]*)"(?: within (\d+) seconds?)?$/, async function (selector, attr, value, sec) {
279
+ Then(/^"([^"]*)" should have attribute "([^"]*)" with value "([^"]*)"(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, attr, value, sec) {
248
280
  const loc = this.page.locator(selector).first();
249
281
  await poll(
250
282
  () => loc.getAttribute(attr),
251
283
  (v) => v === value,
252
284
  parseTimeout(sec),
253
- `Expected "${selector}" attribute "${attr}" to be "${value}"`
285
+ `Expected "${selector}" attribute "${attr}" to be "${value}"`,
286
+ registryContext(this, selector, (s) => `"${s}" should have attribute "${attr}" with value "${value}"${within(sec)}`)
254
287
  );
255
288
  });
256
289
 
@@ -264,13 +297,14 @@ Then(/^"([^"]*)" should have attribute "([^"]*)" with value "([^"]*)"(?: within
264
297
  * Example #5: Then "[data-testid=card]" should have class "highlighted"
265
298
  *
266
299
  */
267
- Then(/^"([^"]*)" should have class "([^"]*)"(?: within (\d+) seconds?)?$/, async function (selector, cls, sec) {
300
+ Then(/^"([^"]*)" should have class "([^"]*)"(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (selector, cls, sec) {
268
301
  const loc = this.page.locator(selector).first();
269
302
  await poll(
270
303
  () => loc.getAttribute('class'),
271
304
  (v) => (v || '').split(/\s+/).includes(cls),
272
305
  parseTimeout(sec),
273
- `Expected "${selector}" to have class "${cls}"`
306
+ `Expected "${selector}" to have class "${cls}"`,
307
+ registryContext(this, selector, (s) => `"${s}" should have class "${cls}"${within(sec)}`)
274
308
  );
275
309
  });
276
310
 
@@ -298,7 +332,7 @@ When(/^(I |we )*click the "([^"]*)" (button|link|tab|menuitem|checkbox|radio|opt
298
332
  * Example #5: Then the "Premium" radio should be visible
299
333
  *
300
334
  */
301
- Then(/^the "([^"]*)" (button|link|tab|menuitem|checkbox|radio|option) should be visible(?: within (\d+) seconds?)?$/, async function (name, role, sec) {
335
+ Then(/^the "([^"]*)" (button|link|tab|menuitem|checkbox|radio|option) should be visible(?: within (\d+) seconds?)?$/, OWN_LENGTH, async function (name, role, sec) {
302
336
  const loc = this.page.getByRole(role, { name }).first();
303
337
  await poll(
304
338
  () => loc.isVisible(),