@itmetsam/samurai-framework 0.10.0 → 0.12.1

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 (326) hide show
  1. package/README.md +3 -4
  2. package/dist/assert/assertion-error.d.ts +1 -1
  3. package/dist/assert/expect.d.ts +5 -50
  4. package/dist/assert/expect.js +5 -182
  5. package/dist/assert/locator-assertions.d.ts +22 -0
  6. package/dist/assert/locator-assertions.js +61 -0
  7. package/dist/assert/pending-assertions.d.ts +7 -0
  8. package/dist/assert/pending-assertions.js +40 -0
  9. package/dist/assert/text-match.d.ts +4 -0
  10. package/dist/assert/text-match.js +11 -0
  11. package/dist/assert/value-assertions.d.ts +23 -0
  12. package/dist/assert/value-assertions.js +82 -0
  13. package/dist/browser/browser-context.d.ts +0 -1
  14. package/dist/browser/browser-context.js +13 -5
  15. package/dist/browser/browser-finder.js +5 -9
  16. package/dist/browser/browser.d.ts +3 -31
  17. package/dist/browser/browser.js +36 -219
  18. package/dist/browser/chrome-launch.d.ts +2 -1
  19. package/dist/browser/dialog-handling.d.ts +32 -0
  20. package/dist/browser/dialog-handling.js +85 -0
  21. package/dist/browser/document-watcher.d.ts +44 -0
  22. package/dist/browser/document-watcher.js +160 -0
  23. package/dist/browser/download-folders.d.ts +0 -1
  24. package/dist/browser/download-folders.js +7 -15
  25. package/dist/browser/download.js +5 -10
  26. package/dist/browser/downloads-dir.js +2 -2
  27. package/dist/browser/emit.d.ts +7 -0
  28. package/dist/browser/emit.js +16 -0
  29. package/dist/browser/emulation.d.ts +1 -1
  30. package/dist/browser/emulation.js +54 -18
  31. package/dist/browser/file-chooser.js +4 -11
  32. package/dist/browser/history.d.ts +6 -0
  33. package/dist/browser/history.js +89 -0
  34. package/dist/browser/index.d.ts +2 -0
  35. package/dist/browser/index.js +2 -0
  36. package/dist/browser/init-script.d.ts +2 -0
  37. package/dist/browser/init-script.js +16 -0
  38. package/dist/browser/launch-firefox.d.ts +20 -0
  39. package/dist/browser/launch-firefox.js +66 -0
  40. package/dist/browser/launch-flags.d.ts +18 -0
  41. package/dist/browser/launch-flags.js +100 -0
  42. package/dist/browser/lazy.d.ts +21 -0
  43. package/dist/browser/lazy.js +44 -0
  44. package/dist/browser/page-events.d.ts +44 -0
  45. package/dist/browser/page-events.js +58 -0
  46. package/dist/browser/page-logs.js +2 -9
  47. package/dist/browser/page-navigation.d.ts +58 -0
  48. package/dist/browser/page-navigation.js +108 -0
  49. package/dist/browser/page-network.d.ts +69 -0
  50. package/dist/browser/page-network.js +163 -0
  51. package/dist/browser/page-settings.d.ts +35 -0
  52. package/dist/browser/page-settings.js +51 -0
  53. package/dist/browser/page-transfers.d.ts +36 -0
  54. package/dist/browser/page-transfers.js +50 -0
  55. package/dist/browser/page.d.ts +39 -154
  56. package/dist/browser/page.js +134 -758
  57. package/dist/browser/pdf.d.ts +1 -1
  58. package/dist/browser/session.d.ts +16 -0
  59. package/dist/browser/session.js +32 -0
  60. package/dist/browser/viewport.d.ts +19 -0
  61. package/dist/browser/viewport.js +72 -0
  62. package/dist/browser/warm-up.d.ts +1 -1
  63. package/dist/browser/warm-up.js +2 -1
  64. package/dist/browsers/index.d.ts +1 -1
  65. package/dist/browsers/index.js +1 -1
  66. package/dist/browsers/pins.d.ts +0 -2
  67. package/dist/browsers/pins.js +0 -2
  68. package/dist/browsers/store.d.ts +0 -2
  69. package/dist/browsers/store.js +1 -2
  70. package/dist/cli/args.d.ts +13 -6
  71. package/dist/cli/args.js +13 -10
  72. package/dist/cli/browsers.d.ts +1 -2
  73. package/dist/cli/browsers.js +2 -2
  74. package/dist/cli/console-reporter.js +3 -2
  75. package/dist/cli/flow-reporter.js +2 -1
  76. package/dist/cli/flow.d.ts +1 -2
  77. package/dist/cli/flow.js +25 -22
  78. package/dist/cli/init.js +2 -7
  79. package/dist/cli/io.d.ts +10 -0
  80. package/dist/cli/io.js +1 -0
  81. package/dist/cli/main.d.ts +3 -10
  82. package/dist/cli/main.js +10 -143
  83. package/dist/cli/paint.d.ts +2 -0
  84. package/dist/cli/paint.js +4 -0
  85. package/dist/cli/record.d.ts +4 -0
  86. package/dist/cli/record.js +93 -0
  87. package/dist/cli/usage.d.ts +1 -0
  88. package/dist/cli/usage.js +58 -0
  89. package/dist/cli/version.d.ts +2 -0
  90. package/dist/cli/version.js +7 -0
  91. package/dist/config/browsers.d.ts +11 -0
  92. package/dist/config/browsers.js +32 -0
  93. package/dist/config/config.js +4 -1
  94. package/dist/config/mask.d.ts +1 -1
  95. package/dist/config/mask.js +7 -2
  96. package/dist/config/run-settings.d.ts +1 -2
  97. package/dist/config/run-settings.js +1 -6
  98. package/dist/config/timeouts.d.ts +2 -0
  99. package/dist/config/timeouts.js +13 -0
  100. package/dist/config/workers.d.ts +14 -0
  101. package/dist/config/workers.js +29 -0
  102. package/dist/flows/run/branch-context.d.ts +14 -0
  103. package/dist/flows/run/branch-context.js +35 -0
  104. package/dist/flows/run/handlers/condition.d.ts +1 -1
  105. package/dist/flows/run/handlers/end.d.ts +1 -1
  106. package/dist/flows/run/handlers/group.d.ts +1 -1
  107. package/dist/flows/run/handlers/index.d.ts +2 -2
  108. package/dist/flows/run/handlers/parallel.d.ts +1 -1
  109. package/dist/flows/run/handlers/start.d.ts +1 -1
  110. package/dist/flows/run/handlers/support.d.ts +3 -27
  111. package/dist/flows/run/handlers/test.d.ts +1 -1
  112. package/dist/flows/run/handlers/types.d.ts +27 -0
  113. package/dist/flows/run/handlers/types.js +1 -0
  114. package/dist/flows/run/index.d.ts +1 -1
  115. package/dist/flows/run/prepare-flow.d.ts +14 -0
  116. package/dist/flows/run/prepare-flow.js +44 -0
  117. package/dist/flows/run/project.d.ts +33 -2
  118. package/dist/flows/run/project.js +139 -57
  119. package/dist/flows/run/run.d.ts +3 -4
  120. package/dist/flows/run/run.js +23 -193
  121. package/dist/flows/run/walker.d.ts +56 -0
  122. package/dist/flows/run/walker.js +225 -0
  123. package/dist/flows/steps/catalog.d.ts +1 -1
  124. package/dist/flows/steps/handler.d.ts +1 -1
  125. package/dist/flows/steps/set.d.ts +1 -1
  126. package/dist/index.js +1 -1
  127. package/dist/locator/actionability.d.ts +33 -0
  128. package/dist/locator/actionability.js +104 -0
  129. package/dist/locator/chain-resolver.d.ts +20 -0
  130. package/dist/locator/chain-resolver.js +102 -0
  131. package/dist/locator/document-swap.d.ts +1 -0
  132. package/dist/locator/document-swap.js +11 -0
  133. package/dist/locator/element-state.d.ts +3 -1
  134. package/dist/locator/element-state.js +11 -3
  135. package/dist/locator/file-actions.d.ts +35 -0
  136. package/dist/locator/file-actions.js +55 -0
  137. package/dist/{script/helpers.js → locator/helper-realm.js} +2 -2
  138. package/dist/locator/input-actions.d.ts +18 -0
  139. package/dist/locator/input-actions.js +80 -0
  140. package/dist/locator/label-locator.d.ts +1 -1
  141. package/dist/locator/label-locator.js +5 -12
  142. package/dist/locator/locator.d.ts +14 -37
  143. package/dist/locator/locator.js +68 -424
  144. package/dist/locator/page-scripts.d.ts +16 -0
  145. package/dist/locator/page-scripts.js +54 -0
  146. package/dist/locator/page-search.d.ts +10 -0
  147. package/dist/locator/page-search.js +19 -0
  148. package/dist/locator/selector-errors.d.ts +0 -4
  149. package/dist/locator/selector-errors.js +0 -7
  150. package/dist/locator/selector.d.ts +14 -13
  151. package/dist/locator/selector.js +10 -16
  152. package/dist/locator/text-locator.d.ts +1 -1
  153. package/dist/locator/text-locator.js +5 -9
  154. package/dist/logger/index.d.ts +6 -0
  155. package/dist/logger/index.js +14 -7
  156. package/dist/network/bidi-wire.d.ts +10 -0
  157. package/dist/network/bidi-wire.js +38 -0
  158. package/dist/network/intercept.d.ts +30 -0
  159. package/dist/network/intercept.js +130 -0
  160. package/dist/network/network-tracker.d.ts +10 -47
  161. package/dist/network/network-tracker.js +34 -68
  162. package/dist/network/network-types.d.ts +33 -0
  163. package/dist/network/network-types.js +1 -0
  164. package/dist/network/network-wait.d.ts +7 -2
  165. package/dist/network/network-wait.js +14 -4
  166. package/dist/network/response.d.ts +1 -1
  167. package/dist/network/response.js +1 -1
  168. package/dist/network/route.d.ts +92 -0
  169. package/dist/network/route.js +142 -0
  170. package/dist/network/router.d.ts +6 -91
  171. package/dist/network/router.js +25 -258
  172. package/dist/recorder/expectation.d.ts +5 -0
  173. package/dist/recorder/expectation.js +20 -0
  174. package/dist/recorder/files-recorder.d.ts +30 -0
  175. package/dist/recorder/files-recorder.js +88 -0
  176. package/dist/recorder/normalise.d.ts +17 -6
  177. package/dist/recorder/normalise.js +96 -91
  178. package/dist/recorder/options.d.ts +56 -0
  179. package/dist/recorder/options.js +1 -0
  180. package/dist/recorder/page-messages.d.ts +35 -0
  181. package/dist/recorder/page-messages.js +26 -0
  182. package/dist/recorder/ranking.js +1 -0
  183. package/dist/recorder/realms.d.ts +6 -0
  184. package/dist/recorder/realms.js +13 -0
  185. package/dist/recorder/recorder.d.ts +10 -74
  186. package/dist/recorder/recorder.js +39 -199
  187. package/dist/recorder/session-browser.d.ts +22 -0
  188. package/dist/recorder/session-browser.js +21 -0
  189. package/dist/recorder/session-secrets.d.ts +8 -0
  190. package/dist/recorder/session-secrets.js +45 -0
  191. package/dist/recorder/session.d.ts +5 -14
  192. package/dist/recorder/session.js +22 -120
  193. package/dist/recorder/spec-source.d.ts +39 -0
  194. package/dist/recorder/spec-source.js +84 -0
  195. package/dist/recorder/toolbar/action-guard.d.ts +21 -0
  196. package/dist/recorder/toolbar/action-guard.js +43 -0
  197. package/dist/recorder/toolbar/actions/assert.d.ts +4 -0
  198. package/dist/recorder/toolbar/actions/assert.js +52 -0
  199. package/dist/recorder/toolbar/actions/insert.d.ts +6 -0
  200. package/dist/recorder/toolbar/actions/insert.js +93 -0
  201. package/dist/recorder/toolbar/actions/pick.d.ts +8 -0
  202. package/dist/recorder/toolbar/actions/pick.js +26 -0
  203. package/dist/recorder/toolbar/actions/reply.d.ts +7 -0
  204. package/dist/recorder/toolbar/actions/reply.js +10 -0
  205. package/dist/recorder/toolbar/controller-fixture.d.ts +47 -0
  206. package/dist/recorder/toolbar/controller-fixture.js +129 -0
  207. package/dist/recorder/toolbar/controller.d.ts +12 -78
  208. package/dist/recorder/toolbar/controller.js +35 -247
  209. package/dist/recorder/toolbar/inspect.d.ts +1 -3
  210. package/dist/recorder/toolbar/inspect.js +2 -2
  211. package/dist/recorder/toolbar/page-scope.d.ts +19 -0
  212. package/dist/recorder/toolbar/page-scope.js +43 -0
  213. package/dist/recorder/toolbar/protocol.d.ts +2 -1
  214. package/dist/recorder/toolbar/source/attach.d.ts +2 -0
  215. package/dist/recorder/toolbar/source/attach.js +41 -0
  216. package/dist/recorder/toolbar/source/dom.d.ts +2 -0
  217. package/dist/recorder/toolbar/source/dom.js +47 -0
  218. package/dist/recorder/toolbar/source/drag.d.ts +2 -0
  219. package/dist/recorder/toolbar/source/drag.js +32 -0
  220. package/dist/recorder/toolbar/source/events-page.d.ts +2 -0
  221. package/dist/recorder/toolbar/source/events-page.js +67 -0
  222. package/dist/recorder/toolbar/source/events-toolbar.d.ts +2 -0
  223. package/dist/recorder/toolbar/source/events-toolbar.js +35 -0
  224. package/dist/recorder/toolbar/source/fields.d.ts +2 -0
  225. package/dist/recorder/toolbar/source/fields.js +44 -0
  226. package/dist/recorder/toolbar/source/handlers.d.ts +2 -0
  227. package/dist/recorder/toolbar/source/handlers.js +134 -0
  228. package/dist/recorder/toolbar/source/names.d.ts +2 -0
  229. package/dist/recorder/toolbar/source/names.js +12 -0
  230. package/dist/recorder/toolbar/source/picking.d.ts +2 -0
  231. package/dist/recorder/toolbar/source/picking.js +72 -0
  232. package/dist/recorder/toolbar/source/placement.d.ts +2 -0
  233. package/dist/recorder/toolbar/source/placement.js +45 -0
  234. package/dist/recorder/toolbar/source/recorder-side.d.ts +2 -0
  235. package/dist/recorder/toolbar/source/recorder-side.js +54 -0
  236. package/dist/recorder/toolbar/source/setup.d.ts +2 -0
  237. package/dist/recorder/toolbar/source/setup.js +50 -0
  238. package/dist/recorder/toolbar/source/views-panels.d.ts +2 -0
  239. package/dist/recorder/toolbar/source/views-panels.js +150 -0
  240. package/dist/recorder/toolbar/source/views-rail.d.ts +2 -0
  241. package/dist/recorder/toolbar/source/views-rail.js +40 -0
  242. package/dist/recorder/toolbar/source/views-render.d.ts +2 -0
  243. package/dist/recorder/toolbar/source/views-render.js +48 -0
  244. package/dist/recorder/toolbar/source.js +30 -856
  245. package/dist/recorder/toolbar/types.d.ts +70 -0
  246. package/dist/recorder/toolbar/types.js +1 -0
  247. package/dist/recorder/toolbar-bridge.d.ts +43 -0
  248. package/dist/recorder/toolbar-bridge.js +106 -0
  249. package/dist/runner/browsers.d.ts +0 -12
  250. package/dist/runner/browsers.js +1 -33
  251. package/dist/runner/options.d.ts +31 -0
  252. package/dist/runner/options.js +1 -0
  253. package/dist/runner/pooled-run.d.ts +43 -0
  254. package/dist/runner/pooled-run.js +75 -0
  255. package/dist/runner/ports.d.ts +2 -0
  256. package/dist/runner/ports.js +2 -0
  257. package/dist/runner/registry.d.ts +1 -1
  258. package/dist/runner/registry.js +1 -1
  259. package/dist/runner/reporter.d.ts +31 -10
  260. package/dist/runner/reporter.js +39 -6
  261. package/dist/runner/run-test.d.ts +16 -0
  262. package/dist/runner/run-test.js +178 -0
  263. package/dist/runner/run.d.ts +5 -3
  264. package/dist/runner/run.js +28 -29
  265. package/dist/runner/select.d.ts +24 -0
  266. package/dist/runner/select.js +77 -0
  267. package/dist/runner/test-dir.d.ts +13 -0
  268. package/dist/runner/test-dir.js +27 -0
  269. package/dist/runner/test-runner.d.ts +25 -56
  270. package/dist/runner/test-runner.js +81 -270
  271. package/dist/runner/worker-pool.d.ts +67 -0
  272. package/dist/runner/worker-pool.js +275 -0
  273. package/dist/runner/worker-process.d.ts +6 -0
  274. package/dist/runner/worker-process.js +54 -0
  275. package/dist/runner/worker-protocol.d.ts +67 -0
  276. package/dist/runner/worker-protocol.js +1 -0
  277. package/dist/runner/worker-session.d.ts +7 -0
  278. package/dist/runner/worker-session.js +60 -0
  279. package/dist/runner/worker.d.ts +26 -0
  280. package/dist/runner/worker.js +121 -0
  281. package/dist/runner/workers-option.d.ts +15 -0
  282. package/dist/runner/workers-option.js +22 -0
  283. package/dist/script/call-function.d.ts +1 -9
  284. package/dist/script/call-function.js +2 -19
  285. package/dist/script/element-handle.d.ts +1 -2
  286. package/dist/script/element-handle.js +1 -2
  287. package/dist/script/serialize.d.ts +3 -12
  288. package/dist/script/serialize.js +53 -62
  289. package/dist/steps/parse/call.d.ts +3 -0
  290. package/dist/steps/parse/call.js +81 -0
  291. package/dist/steps/parse/expectation.d.ts +5 -0
  292. package/dist/steps/parse/expectation.js +71 -0
  293. package/dist/steps/parse/file-entry.d.ts +4 -0
  294. package/dist/steps/parse/file-entry.js +74 -0
  295. package/dist/steps/parse/literals.d.ts +4 -0
  296. package/dist/steps/parse/literals.js +28 -0
  297. package/dist/steps/parse/step.d.ts +4 -0
  298. package/dist/steps/parse/step.js +81 -0
  299. package/dist/steps/parse.js +2 -323
  300. package/dist/transport/bidi-connection.d.ts +4 -15
  301. package/dist/transport/bidi-connection.js +9 -63
  302. package/dist/transport/log-redaction.d.ts +13 -0
  303. package/dist/transport/log-redaction.js +51 -0
  304. package/dist/transport/subscriptions.js +18 -13
  305. package/dist/transport/unsupported.d.ts +7 -0
  306. package/dist/transport/unsupported.js +13 -0
  307. package/dist/types/bidi-modules/browser.d.ts +1 -12
  308. package/dist/types/bidi-modules/browsing-context.d.ts +8 -18
  309. package/dist/types/bidi-modules/emulation.d.ts +29 -21
  310. package/dist/types/bidi-modules/input.d.ts +1 -9
  311. package/dist/types/bidi-modules/network.d.ts +29 -24
  312. package/dist/types/bidi-modules/script.d.ts +0 -9
  313. package/dist/types/bidi-modules/session.d.ts +0 -8
  314. package/dist/types/bidi-modules/storage.d.ts +0 -5
  315. package/dist/types/bidi.d.ts +7 -37
  316. package/dist/types/config.d.ts +12 -0
  317. package/dist/types/test.d.ts +8 -3
  318. package/dist/wait/wait-until.d.ts +1 -5
  319. package/dist/wait/wait-until.js +7 -16
  320. package/package.json +3 -2
  321. package/dist/config/default.d.ts +0 -2
  322. package/dist/config/default.js +0 -3
  323. package/dist/types/bidi-modules/web-extensions.d.ts +0 -9
  324. package/dist/types/bidi-protocols/command.d.ts +0 -7
  325. package/dist/types/bidi-protocols/event.d.ts +0 -17
  326. /package/dist/{script/helpers.d.ts → locator/helper-realm.d.ts} +0 -0
@@ -12,35 +12,44 @@ export interface EmulationCommands {
12
12
  params: SetGeolocationOverrideParameters;
13
13
  result: SetGeolocationOverrideResult;
14
14
  };
15
- "emulation.setLocaleOverride": { params: SetLocaleOverrideParameters; result: SetLocaleOverrideResult };
16
- "emulation.setNetworkConditions": { params: SetNetworkConditionsParameters; result: EmptyResult };
15
+ "emulation.setLocaleOverride": {
16
+ params: SetLocaleOverrideParameters;
17
+ result: SetLocaleOverrideResult;
18
+ };
19
+ "emulation.setNetworkConditions": {
20
+ params: SetNetworkConditionsParameters;
21
+ result: EmptyResult;
22
+ };
17
23
  "emulation.setScreenOrientationOverride": {
18
24
  params: SetScreenOrientationOverrideParameters;
19
25
  result: SetScreenOrientationOverrideResult;
20
26
  };
21
- "emulation.setScreenSettingsOverride": { params: SetScreenSettingsOverrideParameters; result: EmptyResult };
22
- "emulation.setScriptingEnabled": { params: SetScriptingEnabledParameters; result: SetScriptingEnabledResult };
27
+ "emulation.setScreenSettingsOverride": {
28
+ params: SetScreenSettingsOverrideParameters;
29
+ result: EmptyResult;
30
+ };
31
+ "emulation.setScriptingEnabled": {
32
+ params: SetScriptingEnabledParameters;
33
+ result: SetScriptingEnabledResult;
34
+ };
23
35
  "emulation.setScrollbarTypeOverride": {
24
36
  params: SetScrollbarTypeOverrideParameters;
25
37
  result: SetScrollbarTypeOverrideResult;
26
38
  };
27
- "emulation.setTimezoneOverride": { params: SetTimezoneOverrideParameters; result: SetTimezoneOverrideResult };
28
- "emulation.setTouchOverride": { params: SetTouchOverrideParameters; result: SetTouchOverrideResult };
29
- "emulation.setUserAgentOverride": { params: SetUserAgentOverrideParameters; result: SetUserAgentOverrideResult };
39
+ "emulation.setTimezoneOverride": {
40
+ params: SetTimezoneOverrideParameters;
41
+ result: SetTimezoneOverrideResult;
42
+ };
43
+ "emulation.setTouchOverride": {
44
+ params: SetTouchOverrideParameters;
45
+ result: SetTouchOverrideResult;
46
+ };
47
+ "emulation.setUserAgentOverride": {
48
+ params: SetUserAgentOverrideParameters;
49
+ result: SetUserAgentOverrideResult;
50
+ };
30
51
  }
31
52
 
32
- /** Union of all possible result types returned by emulation module commands. */
33
- export type EmulationResult =
34
- | SetForcedColorsModeThemeOverrideResult
35
- | SetGeolocationOverrideResult
36
- | SetLocaleOverrideResult
37
- | SetScreenOrientationOverrideResult
38
- | SetScriptingEnabledResult
39
- | SetScrollbarTypeOverrideResult
40
- | SetTimezoneOverrideResult
41
- | SetTouchOverrideResult
42
- | SetUserAgentOverrideResult;
43
-
44
53
  /** Result of `emulation.setForcedColorsModeThemeOverride`. */
45
54
  export type SetForcedColorsModeThemeOverrideResult = EmptyResult;
46
55
  /** Result of `emulation.setGeolocationOverride`. */
@@ -108,8 +117,7 @@ export interface GeolocationCoordinatesResponse {
108
117
 
109
118
  /** Either a successful coordinates override or an error response. */
110
119
  export type GeolocationOverrideResponse =
111
- | GeolocationCoordinatesResponse
112
- | GeolocationCoordinatesResponseError;
120
+ GeolocationCoordinatesResponse | GeolocationCoordinatesResponseError;
113
121
 
114
122
  /** Parameters for `emulation.setGeolocationOverride`. */
115
123
  export type SetGeolocationOverrideParameters = GeolocationOverrideResponse & {
@@ -68,10 +68,7 @@ export interface PointerParameters {
68
68
 
69
69
  /** A single action for a pointer input source. */
70
70
  export type PointerSourceAction =
71
- | PauseAction
72
- | PointerDownAction
73
- | PointerUpAction
74
- | PointerMoveAction;
71
+ PauseAction | PointerDownAction | PointerUpAction | PointerMoveAction;
75
72
 
76
73
  /** Actions for a wheel input source. */
77
74
  export interface WheelSourceActions {
@@ -191,11 +188,6 @@ export interface FileDialogOpened {
191
188
  params: FileDialogInfo;
192
189
  }
193
190
 
194
- export type InputResult =
195
- | PerformActionResult
196
- | ReleaseActionResult
197
- | SetFilesResult;
198
-
199
191
  export type PerformActionResult = EmptyResult;
200
192
  export type ReleaseActionResult = EmptyResult;
201
193
  export type SetFilesResult = EmptyResult;
@@ -14,7 +14,10 @@ export interface NetworkCommands {
14
14
  };
15
15
  result: AddInterceptResult;
16
16
  };
17
- "network.removeIntercept": { params: { intercept: Intercept }; result: RemoveInterceptResult };
17
+ "network.removeIntercept": {
18
+ params: { intercept: Intercept };
19
+ result: RemoveInterceptResult;
20
+ };
18
21
  /** Lets a blocked request go on, optionally modified. */
19
22
  "network.continueRequest": {
20
23
  params: {
@@ -42,7 +45,11 @@ export interface NetworkCommands {
42
45
  "network.continueWithAuth": {
43
46
  params:
44
47
  | { request: Request; action: "default" | "cancel" }
45
- | { request: Request; action: "provideCredentials"; credentials: AuthCredentials };
48
+ | {
49
+ request: Request;
50
+ action: "provideCredentials";
51
+ credentials: AuthCredentials;
52
+ };
46
53
  result: ContinueWithAuthResult;
47
54
  };
48
55
  /** Answers a blocked request without contacting the server. */
@@ -57,9 +64,15 @@ export interface NetworkCommands {
57
64
  };
58
65
  result: ProvideResponseResult;
59
66
  };
60
- "network.failRequest": { params: { request: Request }; result: FailRequestResult };
67
+ "network.failRequest": {
68
+ params: { request: Request };
69
+ result: FailRequestResult;
70
+ };
61
71
  "network.setCacheBehavior": {
62
- params: { cacheBehavior: "default" | "bypass"; contexts?: BrowsingContext[] | undefined };
72
+ params: {
73
+ cacheBehavior: "default" | "bypass";
74
+ contexts?: BrowsingContext[] | undefined;
75
+ };
63
76
  result: SetCacheBehaviorResult;
64
77
  };
65
78
  /** Starts retaining response bodies for later `network.getData`. */
@@ -73,7 +86,10 @@ export interface NetworkCommands {
73
86
  };
74
87
  result: AddDataCollectorResult;
75
88
  };
76
- "network.removeDataCollector": { params: { collector: Collector }; result: RemoveDataCollectorResult };
89
+ "network.removeDataCollector": {
90
+ params: { collector: Collector };
91
+ result: RemoveDataCollectorResult;
92
+ };
77
93
  "network.getData": {
78
94
  params: {
79
95
  dataType: DataType;
@@ -89,9 +105,14 @@ export interface NetworkCommands {
89
105
  };
90
106
  }
91
107
 
92
- export type InterceptPhase = "beforeRequestSent" | "responseStarted" | "authRequired";
108
+ export type InterceptPhase =
109
+ "beforeRequestSent" | "responseStarted" | "authRequired";
93
110
  export type DataType = "request" | "response";
94
- export type AuthCredentials = { type: "password"; username: string; password: string };
111
+ export type AuthCredentials = {
112
+ type: "password";
113
+ username: string;
114
+ password: string;
115
+ };
95
116
  export type UrlPattern =
96
117
  | { type: "string"; pattern: string }
97
118
  | {
@@ -202,7 +223,7 @@ export interface BaseParameters {
202
223
  /** Whether this request is currently blocked by an active intercept. */
203
224
  isBlocked: boolean;
204
225
  navigation: Navigation | null;
205
- redirectCount: Number;
226
+ redirectCount: number;
206
227
  request: RequestData;
207
228
  timestamp: number;
208
229
  userContext?: UserContext | null;
@@ -301,22 +322,6 @@ export interface ResponseStarted {
301
322
  params: ResponseStartedParameters;
302
323
  }
303
324
 
304
- /** Union of all possible result types returned by network module commands. */
305
- export type NetworkResult =
306
- | AddDataCollectorResult
307
- | AddInterceptResult
308
- | ContinueRequestResult
309
- | ContinueResponseResult
310
- | ContinueWithAuthResult
311
- | DisownDataResult
312
- | FailRequestResult
313
- | GetDataResult
314
- | ProvideResponseResult
315
- | RemoveDataCollectorResult
316
- | RemoveInterceptResult
317
- | SetCacheBehaviorResult
318
- | SetExtraHeadersResult;
319
-
320
325
  /** Unique identifier for an active network data collector. */
321
326
  export type Collector = string;
322
327
 
@@ -528,15 +528,6 @@ export interface RealmDestroyedParameters {
528
528
  realm: Realm;
529
529
  }
530
530
 
531
- /** Union of all possible result types returned by script module commands. */
532
- export type ScriptResult =
533
- | AddPreloadScriptResult
534
- | CallFunctionResult
535
- | DisownResult
536
- | EvaluateResult
537
- | GetRealmsResult
538
- | RemovePreloadScriptResult;
539
-
540
531
  /** Unique identifier for a preload script registered via `script.addPreloadScript`. */
541
532
  export type PreloadScript = string;
542
533
 
@@ -38,14 +38,6 @@ export type Subscription = string;
38
38
  /** Defines how user prompts (alerts, confirms, prompts) should be automatically handled. */
39
39
  export type UserPromptHandlerType = "accept" | "dismiss" | "ignore";
40
40
 
41
- /** Union of all possible result types returned by session module commands. */
42
- export type SessionResult =
43
- | EndResult
44
- | NewResult
45
- | StatusResult
46
- | SubscribeResult
47
- | UnsubscribeResult;
48
-
49
41
  /** Result of `session.end`. */
50
42
  export type EndResult = EmptyResult;
51
43
 
@@ -68,11 +68,6 @@ export interface StorageKeyPartitionDescriptor extends Extensible {
68
68
  sourceOrigin?: string;
69
69
  }
70
70
 
71
- export type StorageResult =
72
- | DeleteCookiesResult
73
- | GetCookiesResult
74
- | SetCookieResult;
75
-
76
71
  export interface PartitionKey extends Extensible {
77
72
  userContext?: UserContext;
78
73
  sourceOrigin?: string;
@@ -1,33 +1,16 @@
1
- import type { BrowserCommands, BrowserResult } from "./bidi-modules/browser.js";
1
+ import type { BrowserCommands } from "./bidi-modules/browser.js";
2
2
  import type {
3
3
  BrowsingContextEvents,
4
4
  BrowsingContextModule as BrowsingContextCommands,
5
- BrowsingContextResult,
6
5
  } from "./bidi-modules/browsing-context.js";
7
- import type { EmulationCommands, EmulationResult } from "./bidi-modules/emulation.js";
8
- import type {
9
- InputCommands,
10
- InputEvents,
11
- InputResult,
12
- } from "./bidi-modules/input.js";
6
+ import type { EmulationCommands } from "./bidi-modules/emulation.js";
7
+ import type { InputCommands, InputEvents } from "./bidi-modules/input.js";
13
8
  import type { LogEvents } from "./bidi-modules/log.js";
14
9
  import type { PermissionsCommands } from "./bidi-modules/permissions.js";
15
- import type {
16
- NetworkCommands,
17
- NetworkEvents,
18
- NetworkResult,
19
- } from "./bidi-modules/network.js";
20
- import type {
21
- ScriptCommands,
22
- ScriptEvents,
23
- ScriptResult,
24
- } from "./bidi-modules/script.js";
25
- import type { SessionModule, SessionResult } from "./bidi-modules/session.js";
26
- import type { StorageCommands, StorageResult } from "./bidi-modules/storage.js";
27
- import type { WebExtensionResult } from "./bidi-modules/web-extensions.js";
28
- import type { CommandResponse } from "./bidi-protocols/command.js";
29
- import type { ErrorResponse } from "./bidi-protocols/error.js";
30
- import type { BiDiEvent } from "./bidi-protocols/event.js";
10
+ import type { NetworkCommands, NetworkEvents } from "./bidi-modules/network.js";
11
+ import type { ScriptCommands, ScriptEvents } from "./bidi-modules/script.js";
12
+ import type { SessionModule } from "./bidi-modules/session.js";
13
+ import type { StorageCommands } from "./bidi-modules/storage.js";
31
14
 
32
15
  export type BiDiCommands = BrowserCommands &
33
16
  SessionModule &
@@ -45,19 +28,6 @@ export type BiDiEvents = BrowsingContextEvents &
45
28
  NetworkEvents &
46
29
  ScriptEvents;
47
30
 
48
- export type BiDiMessages = CommandResponse | ErrorResponse | BiDiEvent;
49
-
50
- export type ResultData =
51
- | BrowserResult
52
- | BrowsingContextResult
53
- | EmulationResult
54
- | InputResult
55
- | NetworkResult
56
- | ScriptResult
57
- | SessionResult
58
- | StorageResult
59
- | WebExtensionResult;
60
-
61
31
  export type EmptyResult = Extensible;
62
32
 
63
33
  export interface Extensible {
@@ -26,6 +26,11 @@ export interface SamuraiGroup {
26
26
  tests?: SamuraiTest[];
27
27
  /** The browsers this group's tests run in, instead of the project's `browsers` */
28
28
  browsers?: SupportedBrowser[];
29
+ /**
30
+ * How many of this group's tests may run at the same time. Only `1` has an effect: the group's tests run one
31
+ * after the other, even when the run uses more workers (for tests that share an account or data).
32
+ */
33
+ workers?: number;
29
34
  }
30
35
 
31
36
  export interface SamuraiEnvironment {
@@ -51,6 +56,13 @@ export interface SamuraiTestConfig {
51
56
  * @default ["firefox"]
52
57
  */
53
58
  browsers?: SupportedBrowser[];
59
+ /**
60
+ * How many tests run at the same time, each in a worker process of its own: a whole number from 1, or a share of
61
+ * the CPUs like `"50%"`. `--workers` and `SAMURAI_WORKERS` win over it. A config passed as an object, not read
62
+ * from `samurai.config.ts`, runs on one worker.
63
+ * @default half the CPUs
64
+ */
65
+ workers?: number | string;
54
66
  /**
55
67
  * Browser binaries to launch instead of the builds SAMURAI downloads, relative to the project.
56
68
  * `SAMURAI_FIREFOX_PATH` / `SAMURAI_CHROME_PATH` win over these.
@@ -1,6 +1,6 @@
1
- import type { Browser } from "../browser/browser.ts";
2
- import type Page from "../browser/page.ts";
3
- import type { SupportedBrowser } from "./browser.ts";
1
+ import type { Browser } from "../browser/browser.js";
2
+ import type Page from "../browser/page.js";
3
+ import type { SupportedBrowser } from "./browser.js";
4
4
 
5
5
  /** What a test function receives */
6
6
  export interface TestFixtures {
@@ -8,6 +8,8 @@ export interface TestFixtures {
8
8
  browser: Browser;
9
9
  /** The browser this run of the test is in */
10
10
  browserName: SupportedBrowser;
11
+ /** The worker process running the test; 0 when the run has one worker or none */
12
+ workerIndex: number;
11
13
  /** The chosen environment's variables; reading an unknown name throws */
12
14
  env: Readonly<Record<string, string | number | boolean>>;
13
15
  /** Secrets by name (SAMURAI_SECRET_<NAME>); reading an unset name throws */
@@ -71,6 +73,8 @@ interface TestResultIdentity {
71
73
  file: string;
72
74
  /** The browser the test ran in */
73
75
  browser: SupportedBrowser;
76
+ /** The worker process that ran the test; absent when the test ran in the main process */
77
+ worker?: number;
74
78
  startTime: number;
75
79
  }
76
80
 
@@ -78,6 +82,7 @@ interface TestResultBase {
78
82
  name: string;
79
83
  file: string;
80
84
  browser: SupportedBrowser;
85
+ worker?: number;
81
86
  startTime: number;
82
87
  status: "started";
83
88
  }
@@ -1,8 +1,6 @@
1
1
  export interface WaitOptions {
2
2
  /** Total time (ms) to keep probing; 0 probes exactly once */
3
3
  timeout: number;
4
- /** Time (ms) between probes. @default 100 */
5
- interval?: number;
6
4
  }
7
5
  export declare class WaitTimeoutError<T> extends Error {
8
6
  readonly timeout: number;
@@ -10,11 +8,9 @@ export declare class WaitTimeoutError<T> extends Error {
10
8
  readonly last: T | undefined;
11
9
  constructor(timeout: number, last: T | undefined);
12
10
  }
13
- /** Per-call timeout, else the active run's expect timeout, else config `expect.timeout`, else 5000 */
14
- export declare function resolveTimeout(perCall?: number): Promise<number>;
15
11
  /**
16
12
  * Probes until `isDone(current, previous)` is true and resolves with that result.
17
13
  * Always probes at least once; with `timeout > 0` every probe races the time left.
18
14
  * Probe errors are rethrown immediately. Throws WaitTimeoutError at the deadline.
19
15
  */
20
- export declare function waitUntil<T>(probe: () => Promise<T>, isDone: (current: T, previous: T | undefined) => boolean, { timeout, interval }: WaitOptions): Promise<T>;
16
+ export declare function waitUntil<T>(probe: () => Promise<T>, isDone: (current: T, previous: T | undefined) => boolean, { timeout }: WaitOptions): Promise<T>;
@@ -1,8 +1,6 @@
1
1
  import { setTimeout as sleep } from "node:timers/promises";
2
- import { readConfig } from "../config/config.js";
3
- import { peekRunSettings } from "../config/run-settings.js";
4
- const DEFAULT_TIMEOUT = 5000;
5
- const DEFAULT_INTERVAL = 100;
2
+ /** Time (ms) between probes */
3
+ const POLL_INTERVAL = 100;
6
4
  export class WaitTimeoutError extends Error {
7
5
  constructor(timeout, last) {
8
6
  super(`Condition not met within ${timeout}ms`);
@@ -11,15 +9,6 @@ export class WaitTimeoutError extends Error {
11
9
  this.last = last;
12
10
  }
13
11
  }
14
- /** Per-call timeout, else the active run's expect timeout, else config `expect.timeout`, else 5000 */
15
- export async function resolveTimeout(perCall) {
16
- if (perCall !== undefined)
17
- return perCall;
18
- const run = peekRunSettings();
19
- if (run)
20
- return run.expectTimeout;
21
- return (await readConfig("expect"))?.timeout ?? DEFAULT_TIMEOUT;
22
- }
23
12
  const DEADLINE = Symbol("deadline");
24
13
  /**
25
14
  * Races `probe()` against the time left. Resolves `{ value }` when the probe wins,
@@ -40,7 +29,7 @@ function probeBefore(probe, remaining) {
40
29
  * Always probes at least once; with `timeout > 0` every probe races the time left.
41
30
  * Probe errors are rethrown immediately. Throws WaitTimeoutError at the deadline.
42
31
  */
43
- export async function waitUntil(probe, isDone, { timeout, interval = DEFAULT_INTERVAL }) {
32
+ export async function waitUntil(probe, isDone, { timeout }) {
44
33
  const deadline = Date.now() + timeout;
45
34
  let previous;
46
35
  for (let first = true;; first = false) {
@@ -49,7 +38,9 @@ export async function waitUntil(probe, isDone, { timeout, interval = DEFAULT_INT
49
38
  if (!first && remaining <= 0)
50
39
  throw new WaitTimeoutError(timeout, previous);
51
40
  // timeout 0 keeps the single probe un-raced so it always completes
52
- const result = timeout > 0 ? await probeBefore(probe, remaining) : { value: await probe() };
41
+ const result = timeout > 0
42
+ ? await probeBefore(probe, remaining)
43
+ : { value: await probe() };
53
44
  if (result === DEADLINE)
54
45
  throw new WaitTimeoutError(timeout, previous);
55
46
  if (isDone(result.value, previous))
@@ -58,6 +49,6 @@ export async function waitUntil(probe, isDone, { timeout, interval = DEFAULT_INT
58
49
  const left = deadline - Date.now();
59
50
  if (left <= 0)
60
51
  throw new WaitTimeoutError(timeout, previous);
61
- await sleep(Math.min(interval, left));
52
+ await sleep(Math.min(POLL_INTERVAL, left));
62
53
  }
63
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itmetsam/samurai-framework",
3
- "version": "0.10.0",
3
+ "version": "0.12.1",
4
4
  "description": "Browser test framework over WebDriver BiDi: auto-waiting locators, environments and secrets, a recorder, and a command line.",
5
5
  "main": "dist/api.js",
6
6
  "exports": {
@@ -71,7 +71,8 @@
71
71
  "type": "module",
72
72
  "devDependencies": {
73
73
  "@types/node": "^25.6.0",
74
- "tsx": "^4.21.0"
74
+ "esbuild": "^0.28.2",
75
+ "tsx": "^4.23.15"
75
76
  },
76
77
  "dependencies": {
77
78
  "@puppeteer/browsers": "^3.2.4",
@@ -1,2 +0,0 @@
1
- import type { SamuraiTestConfig } from "../types/config.js";
2
- export declare const config: SamuraiTestConfig;
@@ -1,3 +0,0 @@
1
- export const config = {
2
- srcDir: "./src",
3
- };
@@ -1,9 +0,0 @@
1
- import type { EmptyResult } from "../bidi.js";
2
-
3
- export type WebExtensionResult = InstallResult | UninstallResult;
4
-
5
- export type UninstallResult = EmptyResult;
6
- export type Extension = string;
7
- export interface InstallResult {
8
- extension: Extension;
9
- }
@@ -1,7 +0,0 @@
1
- import type { Extensible, ResultData } from "../bidi.js";
2
-
3
- export interface CommandResponse extends Extensible {
4
- type: "success";
5
- id: number;
6
- result: ResultData;
7
- }
@@ -1,17 +0,0 @@
1
- import type { BrowsingContextEvent } from "../bidi-modules/browsing-context.js";
2
- import type { LogEvent } from "../bidi-modules/log.js";
3
- import type { NetworkEvent } from "../bidi-modules/network.js";
4
- import type { ScriptEvent } from "../bidi-modules/script.js";
5
- import type { Extensible } from "../bidi.js";
6
-
7
- export type BiDiEvent = Extensible &
8
- EventData & {
9
- type: "event";
10
- };
11
-
12
- export type EventData =
13
- | BrowsingContextEvent
14
- | InputEvent
15
- | LogEvent
16
- | NetworkEvent
17
- | ScriptEvent;