@testspectra/cli 1.0.70 → 1.1.0-rc.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 (427) hide show
  1. package/LICENSE.md +48 -0
  2. package/README.md +36 -270
  3. package/bin/.testspectra-runner.hash +1 -0
  4. package/bin/spectra.js +1 -1
  5. package/bin/testspectra-runner +0 -0
  6. package/demo-app/assets/index-BhlW-eXG.css +1 -0
  7. package/demo-app/assets/index-DOtRypCa.js +154 -0
  8. package/demo-app/index.html +2 -2
  9. package/dist/.tsbuildinfo +1 -0
  10. package/dist/commands/__tests__/doctor.test.d.ts +1 -0
  11. package/dist/commands/__tests__/doctor.test.js +39 -0
  12. package/dist/commands/__tests__/init.test.d.ts +1 -0
  13. package/dist/commands/__tests__/init.test.js +148 -0
  14. package/dist/commands/__tests__/license.test.d.ts +1 -0
  15. package/dist/commands/__tests__/license.test.js +13 -0
  16. package/dist/commands/__tests__/refactor.test.d.ts +1 -0
  17. package/dist/commands/__tests__/refactor.test.js +64 -0
  18. package/dist/commands/__tests__/run-e2e.test.d.ts +1 -0
  19. package/dist/commands/__tests__/run-e2e.test.js +422 -0
  20. package/dist/commands/__tests__/run.test.d.ts +1 -0
  21. package/dist/commands/__tests__/run.test.js +273 -0
  22. package/dist/commands/__tests__/watch.test.d.ts +1 -0
  23. package/dist/commands/__tests__/watch.test.js +155 -0
  24. package/dist/commands/add.js +86 -85
  25. package/dist/commands/demo.js +21 -11
  26. package/dist/commands/devices.d.ts +14 -2
  27. package/dist/commands/devices.js +44 -34
  28. package/dist/commands/doctor.d.ts +3 -1
  29. package/dist/commands/doctor.js +43 -264
  30. package/dist/commands/init.d.ts +1 -1
  31. package/dist/commands/init.js +211 -196
  32. package/dist/commands/install.d.ts +4 -0
  33. package/dist/commands/install.js +59 -0
  34. package/dist/commands/license.d.ts +4 -0
  35. package/dist/commands/license.js +30 -0
  36. package/dist/commands/lint.d.ts +5 -0
  37. package/dist/commands/lint.js +55 -0
  38. package/dist/commands/refactor.d.ts +9 -0
  39. package/dist/commands/refactor.js +172 -0
  40. package/dist/commands/run.d.ts +23 -2
  41. package/dist/commands/run.js +322 -111
  42. package/dist/commands/skills.d.ts +9 -0
  43. package/dist/commands/skills.js +28 -0
  44. package/dist/commands/sync-types.d.ts +4 -0
  45. package/dist/commands/sync-types.js +15 -0
  46. package/dist/commands/test.d.ts +17 -0
  47. package/dist/commands/test.js +76 -0
  48. package/dist/commands/update.js +39 -43
  49. package/dist/commands/watch.d.ts +6 -0
  50. package/dist/commands/watch.js +55 -45
  51. package/dist/config/loader.d.ts +1 -1
  52. package/dist/config/loader.js +40 -25
  53. package/dist/config/schema.d.ts +104 -145
  54. package/dist/config/schema.js +36 -45
  55. package/dist/generator/__tests__/tsconfig-isolation.test.d.ts +1 -0
  56. package/dist/generator/__tests__/tsconfig-isolation.test.js +282 -0
  57. package/dist/generator/__tests__/type-generator.test.d.ts +1 -0
  58. package/dist/generator/__tests__/type-generator.test.js +386 -0
  59. package/dist/generator/index.d.ts +2 -0
  60. package/dist/generator/index.js +2 -0
  61. package/dist/generator/tsconfig-generator.d.ts +27 -0
  62. package/dist/generator/tsconfig-generator.js +419 -0
  63. package/dist/generator/type-generator.d.ts +59 -0
  64. package/dist/generator/type-generator.js +740 -0
  65. package/dist/index.d.ts +9 -5
  66. package/dist/index.js +165 -51
  67. package/dist/lifecycle/__tests__/lifecycle-engine.test.d.ts +1 -0
  68. package/dist/lifecycle/__tests__/lifecycle-engine.test.js +290 -0
  69. package/dist/lifecycle/hook-discovery.d.ts +24 -0
  70. package/dist/lifecycle/hook-discovery.js +60 -0
  71. package/dist/lifecycle/hook-dispatcher.d.ts +34 -0
  72. package/dist/lifecycle/hook-dispatcher.js +190 -0
  73. package/dist/lifecycle/index.d.ts +3 -0
  74. package/dist/lifecycle/index.js +3 -0
  75. package/dist/lifecycle/parallel-grouping.d.ts +27 -0
  76. package/dist/lifecycle/parallel-grouping.js +151 -0
  77. package/dist/linter/__tests__/anonymous-export.test.d.ts +1 -0
  78. package/dist/linter/__tests__/anonymous-export.test.js +184 -0
  79. package/dist/linter/__tests__/component-test-imports.test.d.ts +1 -0
  80. package/dist/linter/__tests__/component-test-imports.test.js +115 -0
  81. package/dist/linter/__tests__/shared-lib-boundary.test.d.ts +1 -0
  82. package/dist/linter/__tests__/shared-lib-boundary.test.js +270 -0
  83. package/dist/linter/__tests__/spec-schema.test.d.ts +1 -0
  84. package/dist/linter/__tests__/spec-schema.test.js +369 -0
  85. package/dist/linter/__tests__/step-parity.test.d.ts +1 -0
  86. package/dist/linter/__tests__/step-parity.test.js +372 -0
  87. package/dist/linter/discovery.d.ts +30 -0
  88. package/dist/linter/discovery.js +249 -0
  89. package/dist/linter/extractor.d.ts +67 -0
  90. package/dist/linter/extractor.js +245 -0
  91. package/dist/linter/index.d.ts +7 -0
  92. package/dist/linter/index.js +7 -0
  93. package/dist/linter/parser.d.ts +24 -0
  94. package/dist/linter/parser.js +219 -0
  95. package/dist/linter/schemas/spec.schema.d.ts +83 -0
  96. package/dist/linter/schemas/spec.schema.js +150 -0
  97. package/dist/linter/schemas/suite.schema.d.ts +59 -0
  98. package/dist/linter/schemas/suite.schema.js +83 -0
  99. package/dist/linter/spec-linter.d.ts +23 -0
  100. package/dist/linter/spec-linter.js +630 -0
  101. package/dist/linter/types.d.ts +28 -0
  102. package/dist/linter/types.js +1 -0
  103. package/dist/mobile/__tests__/android-device-e2e.test.d.ts +1 -0
  104. package/dist/mobile/__tests__/android-device-e2e.test.js +53 -0
  105. package/dist/mobile/__tests__/device-pool.test.d.ts +1 -0
  106. package/dist/mobile/__tests__/device-pool.test.js +97 -0
  107. package/dist/mobile/device-pool.d.ts +23 -0
  108. package/dist/mobile/device-pool.js +1 -0
  109. package/dist/mobile/index.d.ts +1 -0
  110. package/dist/mobile/index.js +1 -0
  111. package/dist/refactor/__tests__/refactor-engine.test.d.ts +1 -0
  112. package/dist/refactor/__tests__/refactor-engine.test.js +873 -0
  113. package/dist/refactor/index.d.ts +1 -0
  114. package/dist/refactor/index.js +1 -0
  115. package/dist/refactor/refactor-engine.d.ts +50 -0
  116. package/dist/refactor/refactor-engine.js +587 -0
  117. package/dist/reporter/__tests__/semantic-formatter.test.d.ts +1 -0
  118. package/dist/reporter/__tests__/semantic-formatter.test.js +73 -0
  119. package/dist/reporter/semantic-formatter.d.ts +6 -0
  120. package/dist/reporter/semantic-formatter.js +206 -0
  121. package/dist/reporter/summary-view.d.ts +12 -0
  122. package/dist/reporter/summary-view.js +19 -0
  123. package/dist/reporter/terminal-stream.d.ts +32 -0
  124. package/dist/reporter/terminal-stream.js +82 -0
  125. package/dist/reporter/types.d.ts +2 -0
  126. package/dist/reporter/types.js +1 -0
  127. package/dist/runner/bridge.d.ts +10 -5
  128. package/dist/runner/bridge.js +101 -45
  129. package/dist/runner/reporter.d.ts +32 -2
  130. package/dist/runner/reporter.js +427 -13
  131. package/dist/server/demo.js +43 -44
  132. package/dist/types/generator.d.ts +1 -17
  133. package/dist/types/generator.js +1 -443
  134. package/dist/utils/__tests__/api-server.test.d.ts +1 -0
  135. package/dist/utils/__tests__/api-server.test.js +62 -0
  136. package/dist/utils/__tests__/demo-server.test.d.ts +1 -0
  137. package/dist/utils/__tests__/demo-server.test.js +35 -0
  138. package/dist/utils/api-server.d.ts +19 -0
  139. package/dist/utils/api-server.js +179 -0
  140. package/dist/utils/demo-server.d.ts +5 -0
  141. package/dist/utils/demo-server.js +46 -36
  142. package/package.json +25 -13
  143. package/templates/default/CLAUDE.md +12 -5
  144. package/templates/default/fixtures/apiData.json +24 -0
  145. package/templates/default/package.json +12 -3
  146. package/templates/default/page-objects/AuthPage/mobile.ts +5 -0
  147. package/templates/default/page-objects/AuthPage/web.ts +10 -0
  148. package/templates/default/page-objects/MatchersPage/mobile.ts +66 -17
  149. package/templates/default/page-objects/MatchersPage/web.ts +22 -2
  150. package/templates/default/page-objects/NavigationPage/mobile.ts +11 -2
  151. package/templates/default/page-objects/NavigationPage/web.ts +1 -1
  152. package/templates/default/page-objects/PlaygroundPage/mobile.ts +34 -18
  153. package/templates/default/page-objects/PlaygroundPage/web.ts +4 -2
  154. package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +53 -0
  155. package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/spec.md +19 -0
  156. package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +31 -0
  157. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/android.test.ts +3 -0
  158. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/common.test.ts +3 -0
  159. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +27 -0
  160. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/spec.md +19 -0
  161. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +26 -0
  162. package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/common.test.ts +30 -0
  163. package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/spec.md +22 -0
  164. package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/common.test.ts +27 -0
  165. package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/spec.md +20 -0
  166. package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/spec.md +24 -0
  167. package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/web.test.ts +26 -0
  168. package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/spec.md +37 -0
  169. package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/web.test.ts +21 -0
  170. package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/spec.md +29 -0
  171. package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/web.test.ts +16 -0
  172. package/templates/default/specs/ApiInterception/suite.md +10 -0
  173. package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/common.test.ts +30 -0
  174. package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/spec.md +23 -0
  175. package/templates/default/specs/ApiSeeding/hooks/after/common.hook.ts +16 -0
  176. package/templates/default/specs/ApiSeeding/hooks/before/common.hook.ts +28 -0
  177. package/templates/default/specs/ApiSeeding/suite.md +9 -0
  178. package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/mobile.test.ts +7 -0
  179. package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/spec.md +19 -0
  180. package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/web.test.ts +9 -0
  181. package/templates/default/specs/Authentication/suite.md +9 -0
  182. package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +7 -1
  183. package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/spec.md +5 -0
  184. package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +17 -3
  185. package/templates/default/specs/BrowserContext/TC-0022-history-navigation/mobile.test.ts +17 -0
  186. package/templates/default/specs/BrowserContext/TC-0022-history-navigation/spec.md +28 -0
  187. package/templates/default/specs/BrowserContext/TC-0022-history-navigation/web.test.ts +26 -0
  188. package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/common.test.ts +26 -0
  189. package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/spec.md +7 -0
  190. package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +9 -1
  191. package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/spec.md +5 -0
  192. package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +9 -4
  193. package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/common.test.ts +14 -0
  194. package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/spec.md +21 -0
  195. package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/mobile.test.ts +28 -0
  196. package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/spec.md +29 -0
  197. package/templates/default/specs/DeepLink/suite.md +9 -0
  198. package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +9 -1
  199. package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/spec.md +5 -0
  200. package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +9 -3
  201. package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +27 -1
  202. package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/spec.md +7 -0
  203. package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +27 -6
  204. package/templates/default/specs/ElementMatchers/suite.md +2 -1
  205. package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -0
  206. package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -0
  207. package/templates/default/specs/EnvironmentConfig/suite.md +9 -0
  208. package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/mobile.test.ts +26 -0
  209. package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/spec.md +22 -0
  210. package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/mobile.test.ts +13 -0
  211. package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/spec.md +20 -0
  212. package/templates/default/specs/PermissionRationale/suite.md +9 -0
  213. package/templates/default/specs/Playground/TC-0001-form-controls/mobile.test.ts +4 -1
  214. package/templates/default/specs/Playground/TC-0001-form-controls/spec.md +6 -0
  215. package/templates/default/specs/Playground/TC-0001-form-controls/web.test.ts +4 -4
  216. package/templates/default/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +4 -1
  217. package/templates/default/specs/Playground/TC-0002-toggle-elements/spec.md +6 -0
  218. package/templates/default/specs/Playground/TC-0002-toggle-elements/web.test.ts +3 -3
  219. package/templates/default/spectra.config.ts +22 -31
  220. package/templates/default/support/actions/fillCredentials/mobile.action.ts +3 -3
  221. package/templates/default/support/actions/fillCredentials/web.action.ts +1 -1
  222. package/templates/default/support/actions/seedSession/mobile.action.ts +9 -0
  223. package/templates/default/support/actions/seedSession/web.action.ts +13 -0
  224. package/templates/default/support/steps/togglePlaygroundStates/mobile.step.ts +3 -1
  225. package/templates/default/support/steps/togglePlaygroundStates/web.step.ts +3 -3
  226. package/templates/default/support/steps/verifyPlaygroundState/mobile.step.ts +4 -2
  227. package/templates/default/support/steps/verifyPlaygroundState/web.step.ts +4 -4
  228. package/templates/default/tsconfig.json +3 -1
  229. package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db +0 -0
  230. package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db-shm +0 -0
  231. package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db-wal +0 -0
  232. package/templates/nx/.nx/workspace-data/d/daemon.log +5366 -0
  233. package/templates/nx/.nx/workspace-data/d/server-process.json +3 -0
  234. package/templates/nx/.nx/workspace-data/file-map.json +464 -0
  235. package/templates/nx/.nx/workspace-data/lockfile.hash +1 -0
  236. package/templates/nx/.nx/workspace-data/nx_files.nxt +0 -0
  237. package/templates/nx/.nx/workspace-data/parsed-lock-file.json +13485 -0
  238. package/templates/nx/.nx/workspace-data/project-graph.json +14389 -0
  239. package/templates/nx/CLAUDE.md +2 -2
  240. package/templates/nx/package.json +6 -4
  241. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +27 -0
  242. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/spec.md +12 -0
  243. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +27 -0
  244. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +24 -0
  245. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/spec.md +12 -0
  246. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +24 -0
  247. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/suite.md +9 -0
  248. package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +1 -1
  249. package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +17 -3
  250. package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +1 -1
  251. package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +15 -5
  252. package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +1 -1
  253. package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +9 -4
  254. package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +1 -1
  255. package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +9 -3
  256. package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +1 -1
  257. package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +27 -6
  258. package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -0
  259. package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -0
  260. package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/suite.md +9 -0
  261. package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/mobile.test.ts +1 -1
  262. package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/web.test.ts +4 -4
  263. package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +1 -1
  264. package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/web.test.ts +3 -3
  265. package/templates/nx/pnpm-lock.yaml +6663 -0
  266. package/templates/nx/pnpm-workspace.yaml +2 -1
  267. package/templates/nx/shared/testing/fixtures/apiData.json +24 -0
  268. package/templates/nx/shared/testing/page-objects/MatchersPage/mobile.ts +13 -1
  269. package/templates/nx/shared/testing/page-objects/MatchersPage/web.ts +85 -17
  270. package/templates/nx/shared/testing/page-objects/NavigationPage/mobile.ts +1 -1
  271. package/templates/nx/shared/testing/page-objects/NavigationPage/web.ts +1 -1
  272. package/templates/nx/shared/testing/page-objects/PlaygroundPage/mobile.ts +1 -1
  273. package/templates/nx/shared/testing/page-objects/PlaygroundPage/web.ts +4 -2
  274. package/templates/nx/shared/testing/project.json +19 -0
  275. package/templates/nx/shared/testing/support/actions/fillCredentials/mobile.action.ts +1 -1
  276. package/templates/nx/shared/testing/support/actions/fillCredentials/web.action.ts +1 -1
  277. package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/mobile.step.ts +1 -1
  278. package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/web.step.ts +3 -3
  279. package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/mobile.step.ts +2 -2
  280. package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/web.step.ts +4 -4
  281. package/templates/nx/spectra.config.ts +20 -29
  282. package/templates/nx/tsconfig.json +3 -1
  283. package/templates/react-component/.cursorrules +17 -0
  284. package/templates/react-component/.vscode/extensions.json +5 -0
  285. package/templates/react-component/CLAUDE.md +14 -0
  286. package/templates/react-component/README.md +69 -0
  287. package/templates/react-component/fixtures/component-mock.json +12 -0
  288. package/templates/react-component/global-hooks/after/web.hook.ts +3 -0
  289. package/templates/react-component/global-hooks/before/web.hook.ts +3 -0
  290. package/templates/react-component/package.json +27 -0
  291. package/templates/react-component/page-objects/BadgeComponent/web.ts +23 -0
  292. package/templates/react-component/page-objects/ButtonComponent/web.ts +23 -0
  293. package/templates/react-component/page-objects/InputComponent/web.ts +13 -0
  294. package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/spec.md +18 -0
  295. package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/web.test.tsx +11 -0
  296. package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/spec.md +18 -0
  297. package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/web.test.tsx +10 -0
  298. package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/spec.md +18 -0
  299. package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/web.test.tsx +16 -0
  300. package/templates/react-component/specs/BadgeComponent/suite.md +12 -0
  301. package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/spec.md +19 -0
  302. package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/web.test.tsx +28 -0
  303. package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/spec.md +19 -0
  304. package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/web.test.tsx +22 -0
  305. package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/spec.md +18 -0
  306. package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/web.test.tsx +8 -0
  307. package/templates/react-component/specs/ButtonComponent/suite.md +12 -0
  308. package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/spec.md +20 -0
  309. package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/web.test.tsx +28 -0
  310. package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/spec.md +18 -0
  311. package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/web.test.tsx +9 -0
  312. package/templates/react-component/specs/InputComponent/suite.md +12 -0
  313. package/templates/react-component/spectra.config.ts +27 -0
  314. package/templates/react-component/src/components/Badge/Badge.tsx +60 -0
  315. package/templates/react-component/src/components/Button/Button.tsx +57 -0
  316. package/templates/react-component/src/components/Input/Input.tsx +41 -0
  317. package/templates/react-component/src/test-utils.tsx +23 -0
  318. package/templates/react-component/support/actions/fillInputField/web.action.ts +9 -0
  319. package/templates/react-component/support/steps/verifyButtonState/web.step.ts +12 -0
  320. package/templates/react-component/tsconfig.json +8 -0
  321. package/demo-app/assets/index-DAUlrHTr.css +0 -1
  322. package/demo-app/assets/index-DN2Kb0A8.js +0 -100
  323. package/dist/index.cjs +0 -101
  324. package/dist/plugin.cjs +0 -575
  325. package/dist/plugin.d.ts +0 -16
  326. package/dist/plugin.js +0 -184
  327. package/dist/step/index.d.ts +0 -6
  328. package/dist/step/index.js +0 -6
  329. package/dist/step/matchers.d.ts +0 -14
  330. package/dist/step/matchers.js +0 -114
  331. package/dist/step/proto.d.ts +0 -46
  332. package/dist/step/proto.js +0 -114
  333. package/dist/step/runner/collection.d.ts +0 -13
  334. package/dist/step/runner/collection.js +0 -51
  335. package/dist/step/runner/single.d.ts +0 -21
  336. package/dist/step/runner/single.js +0 -138
  337. package/dist/step/spectra.d.ts +0 -34
  338. package/dist/step/spectra.js +0 -156
  339. package/dist/step/types.d.ts +0 -32
  340. package/dist/step/types.js +0 -5
  341. package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +0 -3
  342. package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +0 -7
  343. package/templates/default/tsconfig.spectra.android.json +0 -46
  344. package/templates/default/tsconfig.spectra.ios.json +0 -46
  345. package/templates/default/tsconfig.spectra.json +0 -22
  346. package/templates/default/tsconfig.spectra.web.json +0 -53
  347. package/templates/nx/fixtures/playgroundData.json +0 -7
  348. package/templates/nx/global-hooks/after/mobile.hook.ts +0 -3
  349. package/templates/nx/global-hooks/after/web.hook.ts +0 -3
  350. package/templates/nx/global-hooks/before/mobile.hook.ts +0 -3
  351. package/templates/nx/global-hooks/before/web.hook.ts +0 -3
  352. package/templates/nx/page-objects/MatchersPage/mobile.ts +0 -21
  353. package/templates/nx/page-objects/MatchersPage/web.ts +0 -23
  354. package/templates/nx/page-objects/NavigationPage/mobile.ts +0 -5
  355. package/templates/nx/page-objects/NavigationPage/web.ts +0 -8
  356. package/templates/nx/page-objects/PlaygroundPage/mobile.ts +0 -26
  357. package/templates/nx/page-objects/PlaygroundPage/web.ts +0 -29
  358. package/templates/nx/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +0 -3
  359. package/templates/nx/specs/BrowserContext/TC-0007-title-and-navigation/spec.md +0 -12
  360. package/templates/nx/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +0 -5
  361. package/templates/nx/specs/BrowserContext/suite.md +0 -9
  362. package/templates/nx/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +0 -3
  363. package/templates/nx/specs/ContentMatchers/TC-0005-text-and-values/spec.md +0 -12
  364. package/templates/nx/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +0 -7
  365. package/templates/nx/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +0 -3
  366. package/templates/nx/specs/ContentMatchers/TC-0006-collections-and-empty/spec.md +0 -12
  367. package/templates/nx/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +0 -6
  368. package/templates/nx/specs/ContentMatchers/suite.md +0 -9
  369. package/templates/nx/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +0 -3
  370. package/templates/nx/specs/ElementMatchers/TC-0003-visibility-and-dom/spec.md +0 -12
  371. package/templates/nx/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +0 -5
  372. package/templates/nx/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +0 -3
  373. package/templates/nx/specs/ElementMatchers/TC-0004-states-and-attributes/spec.md +0 -12
  374. package/templates/nx/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +0 -8
  375. package/templates/nx/specs/ElementMatchers/hooks/after/mobile.hook.ts +0 -1
  376. package/templates/nx/specs/ElementMatchers/hooks/after/web.hook.ts +0 -1
  377. package/templates/nx/specs/ElementMatchers/hooks/afterEach/mobile.hook.ts +0 -1
  378. package/templates/nx/specs/ElementMatchers/hooks/afterEach/web.hook.ts +0 -1
  379. package/templates/nx/specs/ElementMatchers/hooks/before/mobile.hook.ts +0 -1
  380. package/templates/nx/specs/ElementMatchers/hooks/before/web.hook.ts +0 -1
  381. package/templates/nx/specs/ElementMatchers/hooks/beforeEach/mobile.hook.ts +0 -1
  382. package/templates/nx/specs/ElementMatchers/hooks/beforeEach/web.hook.ts +0 -1
  383. package/templates/nx/specs/ElementMatchers/suite.md +0 -9
  384. package/templates/nx/specs/Playground/TC-0001-form-controls/mobile.test.ts +0 -3
  385. package/templates/nx/specs/Playground/TC-0001-form-controls/spec.md +0 -12
  386. package/templates/nx/specs/Playground/TC-0001-form-controls/web.test.ts +0 -6
  387. package/templates/nx/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +0 -3
  388. package/templates/nx/specs/Playground/TC-0002-toggle-elements/spec.md +0 -12
  389. package/templates/nx/specs/Playground/TC-0002-toggle-elements/web.test.ts +0 -6
  390. package/templates/nx/specs/Playground/hooks/after/mobile.hook.ts +0 -1
  391. package/templates/nx/specs/Playground/hooks/after/web.hook.ts +0 -1
  392. package/templates/nx/specs/Playground/hooks/afterEach/mobile.hook.ts +0 -1
  393. package/templates/nx/specs/Playground/hooks/afterEach/web.hook.ts +0 -1
  394. package/templates/nx/specs/Playground/hooks/before/mobile.hook.ts +0 -1
  395. package/templates/nx/specs/Playground/hooks/before/web.hook.ts +0 -1
  396. package/templates/nx/specs/Playground/hooks/beforeEach/mobile.hook.ts +0 -1
  397. package/templates/nx/specs/Playground/hooks/beforeEach/web.hook.ts +0 -1
  398. package/templates/nx/specs/Playground/suite.md +0 -9
  399. package/templates/nx/support/actions/fillCredentials/mobile.action.ts +0 -4
  400. package/templates/nx/support/actions/fillCredentials/web.action.ts +0 -4
  401. package/templates/nx/support/steps/togglePlaygroundStates/mobile.step.ts +0 -3
  402. package/templates/nx/support/steps/togglePlaygroundStates/step.md +0 -7
  403. package/templates/nx/support/steps/togglePlaygroundStates/web.step.ts +0 -5
  404. package/templates/nx/support/steps/verifyPlaygroundState/mobile.step.ts +0 -4
  405. package/templates/nx/support/steps/verifyPlaygroundState/step.md +0 -7
  406. package/templates/nx/support/steps/verifyPlaygroundState/web.step.ts +0 -6
  407. package/templates/nx/tsconfig.spectra.android.json +0 -39
  408. package/templates/nx/tsconfig.spectra.ios.json +0 -39
  409. package/templates/nx/tsconfig.spectra.json +0 -25
  410. package/templates/nx/tsconfig.spectra.shared.json +0 -25
  411. package/templates/nx/tsconfig.spectra.web.json +0 -45
  412. /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/after/mobile.hook.ts +0 -0
  413. /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/after/web.hook.ts +0 -0
  414. /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/afterEach/mobile.hook.ts +0 -0
  415. /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/afterEach/web.hook.ts +0 -0
  416. /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/before/mobile.hook.ts +0 -0
  417. /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/before/web.hook.ts +0 -0
  418. /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/beforeEach/mobile.hook.ts +0 -0
  419. /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/beforeEach/web.hook.ts +0 -0
  420. /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/after/mobile.hook.ts +0 -0
  421. /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/after/web.hook.ts +0 -0
  422. /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/afterEach/mobile.hook.ts +0 -0
  423. /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/afterEach/web.hook.ts +0 -0
  424. /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/before/mobile.hook.ts +0 -0
  425. /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/before/web.hook.ts +0 -0
  426. /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/beforeEach/mobile.hook.ts +0 -0
  427. /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/beforeEach/web.hook.ts +0 -0
@@ -1,22 +1,38 @@
1
- export class PlaygroundPage {
2
- get visibleElement() { return Spectra.get("~visible_element"); }
3
- get hiddenElement() { return Spectra.get("~hidden_element"); }
4
- get existingElement() { return Spectra.get("~existing_element"); }
5
- get removedElement() { return Spectra.get("~removed_element"); }
6
- get enabledButton() { return Spectra.get("~enabled_button"); }
7
- get disabledButton() { return Spectra.get("~disabled_button"); }
8
- get termsCheckbox() { return Spectra.get("~terms_checkbox"); }
9
- get modeRadio() { return Spectra.get("~mode_radio"); }
10
- get emailInput() { return Spectra.get("~email_input"); }
11
- get tokenInput() { return Spectra.get("~token_input"); }
12
- get exactText() { return Spectra.get("~exact_text"); }
13
- get partialText() { return Spectra.get("~partial_text"); }
14
- get activeTab() { return Spectra.get("~active_tab"); }
15
- get navLink() { return Spectra.get("~nav_link"); }
16
- get productItems() { return Spectra.getAll("~product_item"); }
17
- get emptyList() { return Spectra.getAll("~empty_list"); }
1
+ class PlaygroundPage {
2
+ get visibleElement() { return Spectra.get("~playground-visible"); }
3
+ get hiddenElement() { return Spectra.get("~playground-hidden"); }
4
+ get existingElement() { return Spectra.get("~playground-existing"); }
5
+ get removedElement() { return Spectra.get("~playground-removable"); }
6
+ get enabledButton() { return Spectra.get("~enabled-button"); }
7
+ get disabledButton() { return Spectra.get("~pg-disabled-button"); }
8
+ get termsCheckbox() { return Spectra.get("~pg-terms-checkbox"); }
9
+ get modeRadio() { return Spectra.get("~pg-mode-radio"); }
10
+ get emailInput() { return Spectra.get("~pg-email-input"); }
11
+ get tokenInput() { return Spectra.get("~pg-token-input"); }
12
+ get exactText() { return Spectra.get("~exact-text-el"); }
13
+ get partialText() { return Spectra.get("~partial-text-el"); }
14
+ get activeTab() { return Spectra.get("~active-tab-el"); }
15
+ get navLink() { return Spectra.get("~nav-link-el"); }
16
+ get styledElement() { return Spectra.get("~playground-styled-element"); }
17
+ get focusInput() { return Spectra.get("~playground-focus-input"); }
18
+ get productItems() { return Spectra.getAll("~product-item-1, ~product-item-2, ~product-item-3, ~product-item-4"); }
19
+ get emptyList() { return Spectra.getAll("~empty-list-el-item"); }
18
20
 
19
- async open() {}
21
+ async open() {
22
+ try {
23
+ // See MatchersPage.open()'s equivalent comment: waits for the cold-start home screen, then
24
+ // for the drawer Modal to actually finish materializing before clicking a nav item inside
25
+ // it — both races that otherwise surface as an occasional ~10s stall on the next click.
26
+ await Spectra.get("~toggle-sidebar-btn").waitForElement(30000);
27
+
28
+ const isDrawerOpen = await Spectra.get("~close-sidebar-btn").isDisplayed().catch(() => false);
29
+ if (!isDrawerOpen) {
30
+ await Spectra.get("~toggle-sidebar-btn").click();
31
+ await Spectra.get("~close-sidebar-btn").waitForElement(10000);
32
+ }
33
+ await Spectra.get("~nav-item-playground").click();
34
+ } catch {}
35
+ }
20
36
  async fillCredentials(email = Fixture.playgroundData.defaultEmail, token = Fixture.playgroundData.defaultToken) {
21
37
  await this.emailInput.type(email);
22
38
  await this.tokenInput.type(token);
@@ -1,4 +1,4 @@
1
- export class PlaygroundPage {
1
+ class PlaygroundPage {
2
2
  get visibleElement() { return Spectra.get("#demo-visible-el-pg"); }
3
3
  get hiddenElement() { return Spectra.get("#demo-hidden-el-pg"); }
4
4
  get existingElement() { return Spectra.get("#demo-existing-el-pg"); }
@@ -13,11 +13,13 @@ export class PlaygroundPage {
13
13
  get partialText() { return Spectra.get("#demo-partial-text-pg"); }
14
14
  get activeTab() { return Spectra.get("#demo-active-tab-pg"); }
15
15
  get navLink() { return Spectra.get("#demo-nav-link-pg"); }
16
+ get styledElement() { return Spectra.get("#demo-styled-el-pg"); }
17
+ get focusInput() { return Spectra.get("#demo-focus-input-pg"); }
16
18
  get productItems() { return Spectra.getAll(".demo-product-item"); }
17
19
  get emptyList() { return Spectra.getAll("#demo-empty-list-pg > *"); }
18
20
 
19
21
  async open() {
20
- await browser.url("/#playground");
22
+ await Spectra.navigate("/#playground");
21
23
  }
22
24
 
23
25
  async fillCredentials(email = Fixture.playgroundData.defaultEmail, token = Fixture.playgroundData.defaultToken) {
@@ -0,0 +1,53 @@
1
+ it("Mock and assert GET API requests using browser.intercept", async () => {
2
+ // Navigate to API Fetch section
3
+ await MatchersPage.open("api-fetch");
4
+
5
+ // The app fetches the host demo server's self-hosted endpoint (http://localhost:5200/api/posts) —
6
+ // the device's global HTTP proxy (set up transparently at bootstrap) routes it through the
7
+ // worker's mock proxy without the app knowing or needing any special host/prefix, the same
8
+ // way the CDP web driver intercepts traffic for free. Clear any mock left registered by an
9
+ // earlier test in this same continuous session before adding this one.
10
+ Spectra.clearMocks();
11
+ const mock = await Spectra.intercept(
12
+ "api/posts",
13
+ "GET",
14
+ Fixture.apiData.mockPosts
15
+ );
16
+
17
+ // Trigger fetch button in mobile demo app
18
+ await MatchersPage.fetchApiButton.click();
19
+
20
+ // Assert status and mocked elements
21
+ await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK");
22
+ await MatchersPage.fetchedItems.shouldHaveLength(Fixture.apiData.mockPosts.length);
23
+ await MatchersPage.fetchedItems.first().shouldContainText(Fixture.apiData.mockPosts[0].title);
24
+
25
+ // Dynamically update fixture response
26
+ await mock.respondWith([
27
+ { id: 99, title: "Dynamic Updated Mock Title", body: "Updated on the fly" }
28
+ ]);
29
+ await MatchersPage.fetchApiButton.click();
30
+ await MatchersPage.fetchedItems.shouldHaveLength(1);
31
+ await MatchersPage.fetchedItems.first().shouldContainText("Dynamic Updated Mock Title");
32
+
33
+ // Reset to the base mock and queue a single one-time response — asserts a transient state
34
+ // (e.g. one retry attempt) without disturbing what every other call returns.
35
+ Spectra.clearMocks();
36
+ const queuedMock = await Spectra.intercept(
37
+ "api/posts",
38
+ "GET",
39
+ Fixture.apiData.mockPosts
40
+ );
41
+ await queuedMock.respondOnce([
42
+ { id: 777, title: "One-Time Queued Response", body: "Only served once" }
43
+ ]);
44
+
45
+ await MatchersPage.fetchApiButton.click();
46
+ await MatchersPage.fetchedItems.shouldHaveLength(1);
47
+ await MatchersPage.fetchedItems.first().shouldContainText("One-Time Queued Response");
48
+
49
+ // The queued response is consumed by the call above — this one reverts to the base rule.
50
+ await MatchersPage.fetchApiButton.click();
51
+ await MatchersPage.fetchedItems.shouldHaveLength(Fixture.apiData.mockPosts.length);
52
+ await MatchersPage.fetchedItems.first().shouldContainText(Fixture.apiData.mockPosts[0].title);
53
+ });
@@ -0,0 +1,19 @@
1
+ ---
2
+ id: TC-0008-fetch-mocking
3
+ title: Mock and assert GET API requests using browser.intercept
4
+ priority: High
5
+ caseType: Positive
6
+ status: ready-for-automation
7
+ coverage:
8
+ web: automated
9
+ mobile: automated
10
+ ---
11
+
12
+ # Mock and assert GET API requests using browser.intercept
13
+
14
+ ## Test Steps
15
+ 1. Open API fetch section in matchers page
16
+ 2. Intercept GET /api/posts with mock posts fixture data
17
+ 3. Click fetch API button
18
+ 4. Assert status badge displays 200 OK and rendered items match fixture
19
+ 5. Update mock response dynamically and verify updated items rendered
@@ -0,0 +1,31 @@
1
+ it("Mock and assert GET API requests using browser.intercept", async () => {
2
+ // Navigate to API Fetch section
3
+ await MatchersPage.open("api-fetch");
4
+
5
+ // The app fetches the demo server's own self-hosted endpoint (/api/posts) — served by the
6
+ // built-in demo app (started with `--demo`), so no external network is involved. Clear any mock
7
+ // left registered by an earlier test in this same continuous session before adding this one,
8
+ // since rules aren't scoped per-test and the first matching rule wins.
9
+ Spectra.clearMocks();
10
+ const mock = await Spectra.intercept(
11
+ "api/posts",
12
+ "GET",
13
+ Fixture.apiData.mockPosts
14
+ );
15
+
16
+ // Trigger fetch button
17
+ await MatchersPage.fetchApiButton.click();
18
+
19
+ // Assert status and mocked elements
20
+ await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK");
21
+ await MatchersPage.fetchedItems.shouldHaveLength(Fixture.apiData.mockPosts.length);
22
+ await MatchersPage.fetchedItems.first().shouldContainText(Fixture.apiData.mockPosts[0].title);
23
+
24
+ // Dynamically update fixture response
25
+ await mock.respondWith([
26
+ { id: 99, title: "Dynamic Updated Mock Title", body: "Updated on the fly" }
27
+ ]);
28
+ await MatchersPage.fetchApiButton.click();
29
+ await MatchersPage.fetchedItems.shouldHaveLength(1);
30
+ await MatchersPage.fetchedItems.first().shouldContainText("Dynamic Updated Mock Title");
31
+ });
@@ -0,0 +1,3 @@
1
+ it('Mock and assert POST API requests using browser.intercept', async () => {
2
+ // TODO: Implement test steps and assertions
3
+ });
@@ -0,0 +1,3 @@
1
+ it('Mock and assert POST API requests using browser.intercept', async () => {
2
+ // TODO: Implement test steps and assertions
3
+ });
@@ -0,0 +1,27 @@
1
+ it("Mock and assert POST API requests using browser.intercept", async () => {
2
+ // Navigate to API POST section
3
+ await MatchersPage.open("api-post");
4
+
5
+ // Setup POST API interception with status 201 — the app posts to the host demo server's
6
+ // self-hosted endpoint (http://localhost:5200/api/posts), transparently routed through the
7
+ // worker's mock proxy via the device's global HTTP proxy set up at bootstrap.
8
+ Spectra.clearMocks();
9
+ await Spectra.intercept(
10
+ "api/posts",
11
+ "POST",
12
+ Fixture.apiData.mockPostResponse,
13
+ { statusCode: 201 }
14
+ );
15
+
16
+ // Fill in form fields from Fixture
17
+ await MatchersPage.postTitleInput.type(Fixture.apiData.mockNewPost.title);
18
+ await MatchersPage.postBodyInput.type(Fixture.apiData.mockNewPost.body);
19
+
20
+ // Submit POST form
21
+ await MatchersPage.submitPostButton.click();
22
+
23
+ // Assert response elements and status
24
+ await MatchersPage.postStatusBadge.shouldHaveText("201 Created");
25
+ await MatchersPage.postSuccessBanner.shouldBeVisible();
26
+ await MatchersPage.postResponseJson.shouldContainText(Fixture.apiData.mockNewPost.title);
27
+ });
@@ -0,0 +1,19 @@
1
+ ---
2
+ id: TC-0009-post-mocking
3
+ title: Mock and assert POST API requests using browser.intercept
4
+ priority: High
5
+ caseType: Positive
6
+ status: ready-for-automation
7
+ coverage:
8
+ web: automated
9
+ mobile: automated
10
+ ---
11
+
12
+ # Mock and assert POST API requests using browser.intercept
13
+
14
+ ## Test Steps
15
+ 1. Open API POST section in matchers page
16
+ 2. Intercept POST /api/posts with mock response returning 201 status
17
+ 3. Fill post title and post body inputs from fixture
18
+ 4. Click submit POST button
19
+ 5. Assert status badge displays 201 Created and response JSON contains new title
@@ -0,0 +1,26 @@
1
+ it("Mock and assert POST API requests using browser.intercept", async () => {
2
+ // Navigate to API POST section
3
+ await MatchersPage.open("api-post");
4
+
5
+ // Setup POST API interception with status 201 — the app posts to the demo server's own
6
+ // self-hosted endpoint (/api/posts), no external network involved.
7
+ Spectra.clearMocks();
8
+ await Spectra.intercept(
9
+ "api/posts",
10
+ "POST",
11
+ Fixture.apiData.mockPostResponse,
12
+ { statusCode: 201 }
13
+ );
14
+
15
+ // Fill in form fields from Fixture
16
+ await MatchersPage.postTitleInput.type(Fixture.apiData.mockNewPost.title);
17
+ await MatchersPage.postBodyInput.type(Fixture.apiData.mockNewPost.body);
18
+
19
+ // Submit POST form
20
+ await MatchersPage.submitPostButton.click();
21
+
22
+ // Assert response elements and status
23
+ await MatchersPage.postStatusBadge.shouldHaveText("201 Created");
24
+ await MatchersPage.postSuccessBanner.shouldBeVisible();
25
+ await MatchersPage.postResponseJson.shouldContainText(Fixture.apiData.mockNewPost.title);
26
+ });
@@ -0,0 +1,30 @@
1
+ it("Intercept a direct (immediate) response and a late (delayed) response using Fixture data", async () => {
2
+ await MatchersPage.open("api-fetch");
3
+
4
+ // The app fetches the self-hosted demo endpoint (/api/posts on web, the same path served by
5
+ // the demo server and reached through the device proxy on mobile) — no external network, so
6
+ // there's no upstream latency leaking into the "immediate" assertion below. On web, CDP's
7
+ // Fetch domain intercepts it; on Android, the device's global HTTP proxy routes it through the
8
+ // same worker-side mock engine. Neither platform needs the app, or this test, to know anything
9
+ // special about being under test.
10
+ Spectra.clearMocks();
11
+
12
+ // Direct (immediate) response — Fixture data returned with no artificial latency.
13
+ const mock = await Spectra.intercept("api/posts", "GET", Fixture.apiData.mockPosts);
14
+ await MatchersPage.fetchApiButton.click();
15
+ await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK");
16
+ await MatchersPage.fetchedItems.shouldHaveLength(Fixture.apiData.mockPosts.length);
17
+ await MatchersPage.fetchedItems.first().shouldContainText(Fixture.apiData.mockPosts[0].title);
18
+
19
+ // Late (delayed) response — same mock rule, switched to hold the response back via `delayMs`.
20
+ // The loading indicator must still be visible right after the click, proving this is real
21
+ // network-level latency (the request genuinely stays pending) rather than a client-side-only
22
+ // spinner timer. The delay is set past the default assertion timeout on purpose, to demonstrate
23
+ // the per-assertion `{ timeoutMs }` override below — without it, these assertions would fail-fast
24
+ // before the delayed response ever arrives.
25
+ await mock.respondWith(Fixture.apiData.mockPosts, { delayMs: 2500 });
26
+ await MatchersPage.fetchApiButton.click();
27
+ await MatchersPage.fetchLoadingIndicator.shouldBeVisible();
28
+ await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK", { timeoutMs: 3500 });
29
+ await MatchersPage.fetchedItems.shouldHaveLength(Fixture.apiData.mockPosts.length, { timeoutMs: 3500 });
30
+ });
@@ -0,0 +1,22 @@
1
+ ---
2
+ id: TC-0012-direct-and-late-response
3
+ title: Intercept a direct (immediate) response and a late (delayed) response using Fixture data
4
+ priority: High
5
+ caseType: Positive
6
+ status: ready-for-automation
7
+ coverage:
8
+ web: automated
9
+ mobile: automated
10
+ ---
11
+
12
+ # Intercept a direct (immediate) response and a late (delayed) response using Fixture data
13
+
14
+ ## Test Steps
15
+ 1. Open the API fetch section in the matchers page
16
+ 2. Intercept GET /api/posts with mock posts fixture data
17
+ 3. Click the fetch API button
18
+ 4. Assert the status badge displays 200 OK and the immediate fixture items render
19
+ 5. Update the mock response with an artificial 50ms delay
20
+ 6. Click the fetch API button
21
+ 7. Assert the loading indicator is visible while the request is held
22
+ 8. Assert the status badge displays 200 OK and the delayed fixture items render
@@ -0,0 +1,27 @@
1
+ it("Make a genuine (non-intercepted) network call and verify it is recorded", async () => {
2
+ await MatchersPage.open("api-fetch");
3
+
4
+ // Deliberately no Spectra.intercept() call — this is a genuine request that actually leaves
5
+ // the app and hits a real server, not a mock. It targets the demo server's own self-hosted
6
+ // endpoint (started with `--demo`) instead of an external public API, so it's deterministic
7
+ // and fast everywhere. On web the browser reaches localhost directly; on Android it's
8
+ // transparently routed through the device's global HTTP proxy with no matching mock rule, so
9
+ // the worker's proxy just forwards it for real. Clear any mock a previous test in this suite
10
+ // left registered (e.g. against /api/posts) so it can't accidentally catch this request too —
11
+ // this test uses a different resource (/api/todos/1) specifically to avoid that collision,
12
+ // plus a cache-busting query param so a repeat run doesn't get a 304 Not Modified from the
13
+ // device/browser's own HTTP cache.
14
+ Spectra.clearMocks();
15
+ const cacheBuster = Date.now();
16
+ await MatchersPage.fetchCustomUrlInput.type(`http://localhost:5200/api/todos/1?cb=${cacheBuster}`);
17
+ await MatchersPage.fetchApiButton.click();
18
+ await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK");
19
+
20
+ const entry = Spectra.browser.recordedNetwork.find((e) => e.url.includes(`todos/1?cb=${cacheBuster}`));
21
+ if (!entry) {
22
+ throw new Error("Expected a recorded network entry for the real demo-server call, found none");
23
+ }
24
+ if (entry.status !== 200) {
25
+ throw new Error(`Expected recorded entry status 200, got ${entry.status}`);
26
+ }
27
+ });
@@ -0,0 +1,20 @@
1
+ ---
2
+ id: TC-0013-real-network-call-recorded
3
+ title: Make a genuine (non-intercepted) network call and verify it is recorded
4
+ priority: High
5
+ caseType: Positive
6
+ status: ready-for-automation
7
+ coverage:
8
+ web: automated
9
+ mobile: automated
10
+ ---
11
+
12
+ # Make a genuine (non-intercepted) network call and verify it is recorded
13
+
14
+ ## Test Steps
15
+ 1. Open the API fetch section in the matchers page
16
+ 2. Clear any active mocks left by a previous test
17
+ 3. Enter a real (non-intercepted) demo-server todo endpoint URL with a cache-busting query param
18
+ 4. Click the fetch API button
19
+ 5. Assert the status badge displays 200 OK
20
+ 6. Assert the network report records the genuine call with status 200
@@ -0,0 +1,24 @@
1
+ ---
2
+ id: TC-0015-mock-server-sent-events
3
+ title: Mock a Server-Sent Events (EventSource) stream via the existing network-intercept engine
4
+ priority: Medium
5
+ caseType: Positive
6
+ status: ready-for-automation
7
+ coverage:
8
+ web: automated
9
+ mobile: unsupported
10
+ ---
11
+
12
+ # Mock a Server-Sent Events (EventSource) stream via the existing network-intercept engine
13
+
14
+ Mobile coverage is `unsupported`: React Native has no built-in `EventSource` — a real project
15
+ targeting mobile would add a userland SSE client library, at which point whether/how it's
16
+ mockable depends entirely on that library's own networking implementation, not something
17
+ TestSpectra's driver can generalize over.
18
+
19
+ ## Test Steps
20
+ 1. Open the SSE matcher section
21
+ 2. Intercept GET /api/sse-feed with a text/event-stream mock body
22
+ 3. Click the connect button
23
+ 4. Assert two SSE messages render
24
+ 5. Assert the first message contains "hello from mock SSE" and the last contains "second event"
@@ -0,0 +1,26 @@
1
+ it("Mock a Server-Sent Events (EventSource) stream via the existing network-intercept engine", async () => {
2
+ await MatchersPage.open("sse");
3
+
4
+ // EventSource's initial request is a plain HTTP GET under the hood — CDP's Fetch domain
5
+ // intercepts it exactly like any other fetch()/XHR request. Fulfilling it with a
6
+ // text/event-stream body delivers every "data: ...\n\n" block at once; the browser's own
7
+ // EventSource parser still splits that into individual "message" events and dispatches them
8
+ // just as it would for a real stream, which is the part this demo actually cares about.
9
+ //
10
+ // What this can't fake: `Fetch.fulfillRequest` delivers a complete, connection-closing
11
+ // response (there's no way to keep it open indefinitely the way a real SSE endpoint would), so
12
+ // the browser's EventSource treats that closure as a connection error shortly after — the
13
+ // events still arrive and get processed first, but the app's own "CONNECTED" status flips back
14
+ // to disconnected right after, same as it would after a real server unexpectedly closed the
15
+ // connection. So this test verifies the events were received, not that the connection stayed
16
+ // open — genuinely-persistent SSE isn't something a request/response-shaped mock can simulate.
17
+ await Spectra.intercept("/api/sse-feed", "GET", {
18
+ body: 'data: {"text":"hello from mock SSE"}\n\ndata: {"text":"second event"}\n\n',
19
+ headers: { "Content-Type": "text/event-stream" },
20
+ });
21
+
22
+ await Spectra.get("#sse-connect-btn").click();
23
+ await Spectra.getAll(".sse-message-item").shouldHaveLength(2);
24
+ await Spectra.getAll(".sse-message-item").first().shouldContainText("hello from mock SSE");
25
+ await Spectra.getAll(".sse-message-item").last().shouldContainText("second event");
26
+ });
@@ -0,0 +1,37 @@
1
+ ---
2
+ id: TC-0016-bypass-websocket-with-app-level-mock
3
+ title: Bypass a real WebSocket connection via an app-level test-only mock flag
4
+ priority: Medium
5
+ caseType: Positive
6
+ status: ready-for-automation
7
+ coverage:
8
+ web: automated
9
+ mobile: unsupported
10
+ ---
11
+
12
+ # Bypass a real WebSocket connection via an app-level test-only mock flag
13
+
14
+ **Why this isn't network-level interception like `Spectra.intercept()`:** a WebSocket connection
15
+ starts as an HTTP `Upgrade` handshake and then becomes a raw bidirectional frame stream — it's
16
+ never a single request/response CDP's `Fetch` domain can fulfill the way it fulfills a normal
17
+ `fetch()`/`XHR`/`EventSource` request. Chrome DevTools Protocol's WebSocket-related events
18
+ (`Network.webSocketCreated`, `webSocketFrameSent`/`webSocketFrameReceived`, etc.) are
19
+ observation-only — CDP has no command that mocks or rewrites a WS frame in flight. This is a
20
+ genuine protocol-level limitation, not a gap in this driver.
21
+
22
+ The practical workaround, and what this demo shows: the app itself checks for a test-only global
23
+ flag (`window.__mockWebSocketMessages`) and swaps in an in-memory fake socket when present,
24
+ instead of opening a real connection. `Spectra.browser.evaluate()` sets that flag before the app
25
+ connects. This is the same pattern used by Cypress/Playwright test suites for the same reason.
26
+
27
+ Mobile coverage is `unsupported`: React Native's WebSocket implementation is a native module,
28
+ not a page-context global reachable via a browser-style `evaluate()` call — a mobile equivalent
29
+ would need the RN app's own WebSocket client wrapper to support a comparable test-only bypass.
30
+
31
+ ## Test Steps
32
+ 1. Open the WebSocket matcher section
33
+ 2. Set the app-level mock flag via browser.evaluate before the app connects
34
+ 3. Click the connect button
35
+ 4. Assert the connection status displays CONNECTED and two mocked frames render
36
+ 5. Click the disconnect button
37
+ 6. Assert the connection status displays DISCONNECTED
@@ -0,0 +1,21 @@
1
+ it("Bypass a real WebSocket connection via an app-level test-only mock flag", async () => {
2
+ await MatchersPage.open("websocket");
3
+
4
+ // Set BEFORE the app opens its connection — the component checks this flag inside its own
5
+ // connect() handler and, if present, uses an in-memory fake socket instead of a real
6
+ // `new WebSocket(...)`. This is necessarily app-level, not network-level: see this TC's
7
+ // spec.md for why CDP has no way to intercept/mock a WebSocket handshake or its frames the
8
+ // way Spectra.intercept() does for fetch()/XHR/EventSource.
9
+ await Spectra.browser.evaluate(
10
+ "window.__mockWebSocketMessages = ['hello from mock WS', 'second frame']",
11
+ );
12
+
13
+ await Spectra.get("#ws-connect-btn").click();
14
+ await Spectra.get("#ws-connection-status").shouldHaveText("CONNECTED");
15
+ await Spectra.getAll(".ws-message-item").shouldHaveLength(2);
16
+ await Spectra.getAll(".ws-message-item").first().shouldContainText("hello from mock WS");
17
+ await Spectra.getAll(".ws-message-item").last().shouldContainText("second frame");
18
+
19
+ await Spectra.get("#ws-disconnect-btn").click();
20
+ await Spectra.get("#ws-connection-status").shouldHaveText("DISCONNECTED");
21
+ });
@@ -0,0 +1,29 @@
1
+ ---
2
+ id: TC-0017-bypass-captcha-with-test-mode-flag
3
+ title: Bypass a live reCAPTCHA widget via an app-level test-only flag
4
+ priority: Medium
5
+ caseType: Positive
6
+ status: ready-for-automation
7
+ coverage:
8
+ web: automated
9
+ mobile: unsupported
10
+ ---
11
+
12
+ # Bypass a live reCAPTCHA widget via an app-level test-only flag
13
+
14
+ Real reCAPTCHA renders inside a cross-origin iframe (`google.com`), which Google explicitly
15
+ discourages driving via browser automation — there's no `Spectra.intercept()`-style network mock
16
+ for a live third-party widget's challenge/response flow. The demo embeds the real widget (site key
17
+ `6LcWK4QtAAAAAAeA8IAN20JceGQ7L-RWE-LfhZnB`) for visual completeness, but the test itself uses the
18
+ same pattern real projects use in CI: an app-level `window.__bypassCaptcha` flag the submit
19
+ handler honors instead of ever attempting to automate the actual challenge.
20
+
21
+ Mobile coverage is `unsupported`: a native captcha SDK (rather than a page-context script tag)
22
+ would need its own test-only bypass hook, which is outside what a generic web-style demo can show.
23
+
24
+ ## Test Steps
25
+ 1. Open the captcha matcher section
26
+ 2. Click submit without the bypass flag and assert the widget refuses
27
+ 3. Set the app-level bypass flag via browser.evaluate
28
+ 4. Click submit again
29
+ 5. Assert the submission message indicates the form was bypassed for automated testing
@@ -0,0 +1,16 @@
1
+ it("Bypass a live reCAPTCHA widget via an app-level test-only flag", async () => {
2
+ await MatchersPage.open("captcha");
3
+
4
+ // Baseline: without the flag (and no completed challenge), the widget refuses to submit —
5
+ // proving the success below is specifically driven by the bypass flag, not a stale state.
6
+ await Spectra.get("#captcha-submit-btn").click();
7
+ await Spectra.get("#captcha-submit-message").shouldContainText("complete the reCAPTCHA challenge");
8
+
9
+ // Set BEFORE submitting — see this TC's spec.md for why this has to be an app-level bypass
10
+ // rather than a network-level mock (real reCAPTCHA lives in a cross-origin iframe with no
11
+ // request/response Spectra.intercept() could fulfill).
12
+ await Spectra.browser.evaluate("window.__bypassCaptcha = true");
13
+
14
+ await Spectra.get("#captcha-submit-btn").click();
15
+ await Spectra.get("#captcha-submit-message").shouldContainText("bypassed for automated test");
16
+ });
@@ -0,0 +1,10 @@
1
+ ---
2
+ id: suite-api-interception
3
+ name: ApiInterception
4
+ description: REST API network mocking, GET/POST payload interception, and status assertions
5
+ executionOrder: 1.4
6
+ parallel: true
7
+ ---
8
+
9
+ # Suite: ApiInterception
10
+
@@ -0,0 +1,30 @@
1
+ // The `before` hook (hooks/before/common.hook.ts) already ran by the time this test body
2
+ // executes — it seeded a post via a real POST to the demo server's self-hosted API and stashed
3
+ // the result on globalThis for this test to read. Cleanup (hooks/after/common.hook.ts) runs
4
+ // after this whole suite finishes, so it can't be observed from inside the suite's own tests —
5
+ // a separate monitoring suite/run would be how a real project verifies cleanup actually happened.
6
+ //
7
+ // Suite-scoped hooks only run when a worker's whole batch is unambiguously scoped to this one
8
+ // suite (e.g. `spectra run specs/ApiSeeding` or targeting this TC directly) — hook functions are
9
+ // process-global singleton slots, not per-test-case, so a worker batch spanning multiple suites
10
+ // has no correct way to scope suite A's hooks to only run around suite A's own tests, and skips
11
+ // suite-level hooks entirely rather than risk applying the wrong suite's hooks to the wrong
12
+ // tests. Running the FULL default template (`spectra run -t web`/`android`, every suite at once)
13
+ // will legitimately fail this specific test for that reason — that's an inherent limitation of
14
+ // the current worker-batching model, not a bug in this demo.
15
+ it("Verify test data seeded by a before hook via the demo server's self-hosted API is available to the test", async () => {
16
+ const seeding = (globalThis as any).__apiSeeding;
17
+
18
+ if (!seeding?.seededPost) {
19
+ throw new Error("Expected the before hook to have seeded a post onto globalThis.__apiSeeding, found none");
20
+ }
21
+ if (typeof seeding.seededPost.id !== "number") {
22
+ throw new Error(`Expected seeded post to have a numeric id, got ${JSON.stringify(seeding.seededPost.id)}`);
23
+ }
24
+ if (seeding.seededPost.title !== "TestSpectra seeded post") {
25
+ throw new Error(`Expected seeded post title to match, got "${seeding.seededPost.title}"`);
26
+ }
27
+ if (seeding.cleanedUp !== false) {
28
+ throw new Error("Expected cleanedUp to still be false — the after hook hasn't run yet at this point");
29
+ }
30
+ });
@@ -0,0 +1,23 @@
1
+ ---
2
+ id: TC-0014-seed-and-cleanup-via-hooks
3
+ title: Verify test data seeded by a before hook via the demo server's self-hosted API is available to the test
4
+ priority: Medium
5
+ caseType: Positive
6
+ status: ready-for-automation
7
+ coverage:
8
+ web: automated
9
+ mobile: automated
10
+ ---
11
+
12
+ # Verify test data seeded by a before hook via the demo server's self-hosted API is available to the test
13
+
14
+ The before hook seeds against the demo server's self-hosted `/api/posts` (POST), and the after
15
+ hook cleans up via DELETE. Because the hooks run on the host worker (not on the device), the demo
16
+ server must be up on the host — run this suite with `--demo` on any platform, e.g.
17
+ `spectra run "specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/common.test.ts" -t android --demo`.
18
+
19
+ ## Test Steps
20
+ 1. Before hook seeds a post via a real POST to the demo server's self-hosted API and stashes it on globalThis
21
+ 2. Verify the seeded post is present on globalThis
22
+ 3. Assert the seeded post has a numeric id and the expected title
23
+ 4. Assert cleanup has not yet run (the after hook runs after this suite finishes)
@@ -0,0 +1,16 @@
1
+ // Suite-level `after` hook — runs once after this suite's tests complete, regardless of whether
2
+ // they passed, so seeded data is always cleaned up rather than leaking into later runs.
3
+ export default async function () {
4
+ const seeding = (globalThis as any).__apiSeeding;
5
+ if (!seeding?.seededPost?.id) return;
6
+
7
+ const res = await fetch(`http://localhost:5200/api/posts/${seeding.seededPost.id}`, {
8
+ method: "DELETE",
9
+ });
10
+
11
+ if (!res.ok) {
12
+ throw new Error(`ApiSeeding after hook: failed to clean up seeded post ${seeding.seededPost.id} (${res.status})`);
13
+ }
14
+
15
+ seeding.cleanedUp = true;
16
+ }