@testspectra/cli 1.1.8-rc.2 → 1.1.8-rc.21

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 (216) hide show
  1. package/README.md +47 -0
  2. package/bin/.testspectra-runner.hash +1 -1
  3. package/bin/spectra.js +0 -0
  4. package/dist/.tsbuildinfo +1 -1
  5. package/dist/commands/__tests__/cloud-run.test.d.ts +1 -0
  6. package/dist/commands/__tests__/cloud-run.test.js +93 -0
  7. package/dist/commands/__tests__/run-e2e.test.js +49 -49
  8. package/dist/commands/add.js +2 -1
  9. package/dist/commands/cloud-run.d.ts +13 -0
  10. package/dist/commands/cloud-run.js +120 -0
  11. package/dist/commands/devices.js +1 -0
  12. package/dist/commands/docs.d.ts +4 -0
  13. package/dist/commands/docs.js +17 -0
  14. package/dist/commands/doctor.js +1 -0
  15. package/dist/commands/init.js +7 -160
  16. package/dist/commands/install.js +2 -0
  17. package/dist/commands/license.js +1 -0
  18. package/dist/commands/test.js +5 -3
  19. package/dist/generator/__tests__/tsconfig-isolation.test.js +2 -1
  20. package/dist/generator/__tests__/type-generator.test.js +38 -0
  21. package/dist/generator/architecture-doc-generator.d.ts +14 -0
  22. package/dist/generator/architecture-doc-generator.js +82 -0
  23. package/dist/generator/index.d.ts +1 -0
  24. package/dist/generator/index.js +1 -0
  25. package/dist/generator/tsconfig-generator.js +1 -1
  26. package/dist/generator/type-generator.d.ts +5 -2
  27. package/dist/generator/type-generator.js +14 -17
  28. package/dist/index.js +18 -11
  29. package/dist/linter/__tests__/component-test-imports.test.js +51 -51
  30. package/dist/linter/__tests__/shared-lib-boundary.test.js +15 -15
  31. package/dist/linter/__tests__/spec-schema.test.js +167 -167
  32. package/dist/linter/discovery.d.ts +3 -3
  33. package/dist/linter/discovery.js +5 -5
  34. package/dist/linter/schemas/spec.schema.d.ts +2 -2
  35. package/dist/linter/schemas/suite.schema.d.ts +4 -4
  36. package/dist/runner/bridge.js +53 -4
  37. package/package.json +34 -29
  38. package/templates/default/CLAUDE.md +16 -16
  39. package/templates/default/global-hooks/after/mobile.hook.ts +3 -3
  40. package/templates/default/global-hooks/after/web.hook.ts +3 -3
  41. package/templates/default/global-hooks/before/mobile.hook.ts +3 -3
  42. package/templates/default/global-hooks/before/web.hook.ts +3 -3
  43. package/templates/default/package.json +2 -2
  44. package/templates/default/page-objects/AuthPage/mobile.ts +5 -5
  45. package/templates/default/page-objects/AuthPage/web.ts +10 -10
  46. package/templates/default/page-objects/MatchersPage/mobile.ts +70 -70
  47. package/templates/default/page-objects/MatchersPage/web.ts +43 -43
  48. package/templates/default/page-objects/NavigationPage/mobile.ts +14 -14
  49. package/templates/default/page-objects/NavigationPage/web.ts +8 -8
  50. package/templates/default/page-objects/PlaygroundPage/mobile.ts +42 -42
  51. package/templates/default/page-objects/PlaygroundPage/web.ts +31 -31
  52. package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +53 -53
  53. package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/spec.md +19 -19
  54. package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +31 -31
  55. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/android.test.ts +3 -3
  56. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/common.test.ts +3 -3
  57. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +27 -27
  58. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/spec.md +19 -19
  59. package/templates/default/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +26 -26
  60. package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/common.test.ts +30 -30
  61. package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/spec.md +22 -22
  62. package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/common.test.ts +27 -27
  63. package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/spec.md +20 -20
  64. package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/spec.md +24 -24
  65. package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/web.test.ts +26 -26
  66. package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/spec.md +37 -37
  67. package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/web.test.ts +21 -21
  68. package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/spec.md +29 -29
  69. package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/web.test.ts +16 -16
  70. package/templates/default/specs/ApiInterception/suite.md +10 -10
  71. package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/common.test.ts +30 -30
  72. package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/spec.md +23 -23
  73. package/templates/default/specs/ApiSeeding/hooks/after/common.hook.ts +16 -16
  74. package/templates/default/specs/ApiSeeding/hooks/before/common.hook.ts +28 -28
  75. package/templates/default/specs/ApiSeeding/suite.md +9 -9
  76. package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/mobile.test.ts +7 -7
  77. package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/spec.md +19 -19
  78. package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/web.test.ts +9 -9
  79. package/templates/default/specs/Authentication/suite.md +9 -9
  80. package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +9 -9
  81. package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/spec.md +17 -17
  82. package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +19 -19
  83. package/templates/default/specs/BrowserContext/TC-0022-history-navigation/mobile.test.ts +17 -17
  84. package/templates/default/specs/BrowserContext/TC-0022-history-navigation/spec.md +28 -28
  85. package/templates/default/specs/BrowserContext/TC-0022-history-navigation/web.test.ts +26 -26
  86. package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/common.test.ts +26 -26
  87. package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/spec.md +19 -19
  88. package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +11 -11
  89. package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/spec.md +17 -17
  90. package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +11 -11
  91. package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/common.test.ts +14 -14
  92. package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/spec.md +21 -21
  93. package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/mobile.test.ts +28 -28
  94. package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/spec.md +29 -29
  95. package/templates/default/specs/DeepLink/suite.md +9 -9
  96. package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +11 -11
  97. package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/spec.md +17 -17
  98. package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +11 -11
  99. package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +29 -29
  100. package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/spec.md +19 -19
  101. package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +29 -29
  102. package/templates/default/specs/ElementMatchers/suite.md +10 -10
  103. package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -5
  104. package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -16
  105. package/templates/default/specs/EnvironmentConfig/suite.md +9 -9
  106. package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/mobile.test.ts +26 -26
  107. package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/spec.md +22 -22
  108. package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/mobile.test.ts +13 -13
  109. package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/spec.md +20 -20
  110. package/templates/default/specs/PermissionRationale/suite.md +9 -9
  111. package/templates/default/specs/Playground/TC-0001-form-controls/mobile.test.ts +6 -6
  112. package/templates/default/specs/Playground/TC-0001-form-controls/spec.md +18 -18
  113. package/templates/default/specs/Playground/TC-0001-form-controls/web.test.ts +6 -6
  114. package/templates/default/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +6 -6
  115. package/templates/default/specs/Playground/TC-0002-toggle-elements/spec.md +18 -18
  116. package/templates/default/specs/Playground/TC-0002-toggle-elements/web.test.ts +6 -6
  117. package/templates/default/spectra.config.ts +52 -52
  118. package/templates/default/support/actions/fillCredentials/mobile.action.ts +4 -4
  119. package/templates/default/support/actions/fillCredentials/web.action.ts +4 -4
  120. package/templates/default/support/actions/seedSession/mobile.action.ts +9 -9
  121. package/templates/default/support/actions/seedSession/web.action.ts +13 -13
  122. package/templates/default/support/steps/togglePlaygroundStates/mobile.step.ts +5 -5
  123. package/templates/default/support/steps/togglePlaygroundStates/web.step.ts +5 -5
  124. package/templates/default/support/steps/verifyPlaygroundState/mobile.step.ts +6 -6
  125. package/templates/default/support/steps/verifyPlaygroundState/web.step.ts +6 -6
  126. package/templates/docs/ARCHITECTURE.default.md +26 -0
  127. package/templates/docs/ARCHITECTURE.nx.md +119 -0
  128. package/templates/nx/.nx/workspace-data/{59842386-c7c4-44ca-b2c2-20e1700bd13d.db-shm → 70094CFD-E89B-57A1-9619-2FC5F4963C54.db-shm} +0 -0
  129. package/templates/nx/.nx/workspace-data/{59842386-c7c4-44ca-b2c2-20e1700bd13d.db-wal → 70094CFD-E89B-57A1-9619-2FC5F4963C54.db-wal} +0 -0
  130. package/templates/nx/.nx/workspace-data/d/daemon.log +1090 -1577
  131. package/templates/nx/.nx/workspace-data/d/server-process.json +1 -1
  132. package/templates/nx/.nx/workspace-data/file-map.json +56 -56
  133. package/templates/nx/.nx/workspace-data/lockfile.hash +1 -1
  134. package/templates/nx/.nx/workspace-data/nx_files.nxt +0 -0
  135. package/templates/nx/.nx/workspace-data/parsed-lock-file.json +185 -6681
  136. package/templates/nx/.nx/workspace-data/project-graph.json +190 -7434
  137. package/templates/nx/CLAUDE.md +10 -10
  138. package/templates/nx/package.json +3 -3
  139. package/templates/nx/packages/matchers/e2e/project.json +2 -2
  140. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +27 -27
  141. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +27 -27
  142. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +24 -24
  143. package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +24 -24
  144. package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +3 -3
  145. package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +19 -19
  146. package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +3 -3
  147. package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +17 -17
  148. package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +3 -3
  149. package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +11 -11
  150. package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +3 -3
  151. package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +11 -11
  152. package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +3 -3
  153. package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +29 -29
  154. package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -5
  155. package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -16
  156. package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/suite.md +9 -9
  157. package/templates/nx/packages/playground/e2e/project.json +2 -2
  158. package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/mobile.test.ts +3 -3
  159. package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/web.test.ts +6 -6
  160. package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +3 -3
  161. package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/web.test.ts +6 -6
  162. package/templates/nx/pnpm-lock.yaml +6663 -6663
  163. package/templates/nx/pnpm-workspace.yaml +9 -9
  164. package/templates/nx/shared/testing/page-objects/MatchersPage/mobile.ts +33 -33
  165. package/templates/nx/shared/testing/page-objects/MatchersPage/web.ts +91 -91
  166. package/templates/nx/shared/testing/page-objects/NavigationPage/mobile.ts +5 -5
  167. package/templates/nx/shared/testing/page-objects/NavigationPage/web.ts +8 -8
  168. package/templates/nx/shared/testing/page-objects/PlaygroundPage/mobile.ts +26 -26
  169. package/templates/nx/shared/testing/page-objects/PlaygroundPage/web.ts +31 -31
  170. package/templates/nx/shared/testing/project.json +18 -19
  171. package/templates/nx/shared/testing/support/actions/fillCredentials/mobile.action.ts +4 -4
  172. package/templates/nx/shared/testing/support/actions/fillCredentials/web.action.ts +4 -4
  173. package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/mobile.step.ts +3 -3
  174. package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/web.step.ts +5 -5
  175. package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/mobile.step.ts +4 -4
  176. package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/web.step.ts +6 -6
  177. package/templates/nx/spectra.config.ts +52 -52
  178. package/templates/react-component/.cursorrules +17 -17
  179. package/templates/react-component/.vscode/extensions.json +5 -5
  180. package/templates/react-component/CLAUDE.md +14 -14
  181. package/templates/react-component/README.md +69 -69
  182. package/templates/react-component/fixtures/component-mock.json +12 -12
  183. package/templates/react-component/global-hooks/after/web.hook.ts +3 -3
  184. package/templates/react-component/global-hooks/before/web.hook.ts +3 -3
  185. package/templates/react-component/package.json +27 -27
  186. package/templates/react-component/page-objects/BadgeComponent/web.ts +23 -23
  187. package/templates/react-component/page-objects/ButtonComponent/web.ts +23 -23
  188. package/templates/react-component/page-objects/InputComponent/web.ts +13 -13
  189. package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/spec.md +18 -18
  190. package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/web.test.tsx +11 -11
  191. package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/spec.md +18 -18
  192. package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/web.test.tsx +10 -10
  193. package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/spec.md +18 -18
  194. package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/web.test.tsx +16 -16
  195. package/templates/react-component/specs/BadgeComponent/suite.md +12 -12
  196. package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/spec.md +19 -19
  197. package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/web.test.tsx +28 -28
  198. package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/spec.md +19 -19
  199. package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/web.test.tsx +22 -22
  200. package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/spec.md +18 -18
  201. package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/web.test.tsx +8 -8
  202. package/templates/react-component/specs/ButtonComponent/suite.md +12 -12
  203. package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/spec.md +20 -20
  204. package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/web.test.tsx +28 -28
  205. package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/spec.md +18 -18
  206. package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/web.test.tsx +9 -9
  207. package/templates/react-component/specs/InputComponent/suite.md +12 -12
  208. package/templates/react-component/spectra.config.ts +27 -27
  209. package/templates/react-component/src/components/Badge/Badge.tsx +60 -60
  210. package/templates/react-component/src/components/Button/Button.tsx +57 -57
  211. package/templates/react-component/src/components/Input/Input.tsx +41 -41
  212. package/templates/react-component/src/test-utils.tsx +23 -23
  213. package/templates/react-component/support/actions/fillInputField/web.action.ts +9 -9
  214. package/templates/react-component/support/steps/verifyButtonState/web.step.ts +12 -12
  215. package/bin/testspectra-runner.exe +0 -0
  216. /package/templates/nx/.nx/workspace-data/{59842386-c7c4-44ca-b2c2-20e1700bd13d.db → 70094CFD-E89B-57A1-9619-2FC5F4963C54.db} +0 -0
@@ -0,0 +1,93 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { cloudRunCommand, parseTimeoutMs } from '../cloud-run.js';
3
+ const ORIGINAL_ENV = { ...process.env };
4
+ function mockFetchSequence(responses) {
5
+ let call = 0;
6
+ return vi.fn(async (_url, _init) => {
7
+ const res = responses[Math.min(call, responses.length - 1)];
8
+ call += 1;
9
+ return {
10
+ ok: res.ok,
11
+ status: res.status ?? (res.ok ? 200 : 500),
12
+ statusText: 'error',
13
+ json: async () => res.json,
14
+ };
15
+ });
16
+ }
17
+ describe('cloudRunCommand (docs/v2/cloud/git-spec-standards-and-workflow.md)', () => {
18
+ beforeEach(() => {
19
+ process.env = { ...ORIGINAL_ENV, SPECTRA_URL: 'https://cloud.test', SPECTRA_TOKEN: 'gitea-pat-123' };
20
+ process.exitCode = undefined;
21
+ vi.useFakeTimers();
22
+ });
23
+ afterEach(() => {
24
+ process.env = { ...ORIGINAL_ENV };
25
+ vi.restoreAllMocks();
26
+ vi.useRealTimers();
27
+ });
28
+ it('fails fast without SPECTRA_URL/SPECTRA_TOKEN', async () => {
29
+ delete process.env.SPECTRA_URL;
30
+ delete process.env.SPECTRA_TOKEN;
31
+ const fetchSpy = vi.fn();
32
+ vi.stubGlobal('fetch', fetchSpy);
33
+ await cloudRunCommand({ project: 'org/repo', branch: 'main' });
34
+ expect(process.exitCode).toBe(1);
35
+ expect(fetchSpy).not.toHaveBeenCalled();
36
+ });
37
+ it('triggers and returns immediately with --no-wait', async () => {
38
+ const fetchSpy = mockFetchSequence([{ ok: true, json: { job_id: 'job-1', status: 'queued' } }]);
39
+ vi.stubGlobal('fetch', fetchSpy);
40
+ await cloudRunCommand({ project: 'org/repo', branch: 'main', wait: false });
41
+ expect(fetchSpy).toHaveBeenCalledTimes(1);
42
+ const [url, init] = fetchSpy.mock.calls[0];
43
+ expect(url).toBe('https://cloud.test/api/v1/runs/trigger');
44
+ const headers = init.headers;
45
+ expect(headers.Authorization).toBe('Bearer gitea-pat-123');
46
+ expect(JSON.parse(init.body)).toMatchObject({ project_id: 'org/repo', branch: 'main', platform: 'web' });
47
+ expect(process.exitCode).toBeUndefined();
48
+ });
49
+ it('exits 0 when the job reaches done', async () => {
50
+ const fetchSpy = mockFetchSequence([
51
+ { ok: true, json: { job_id: 'job-2', status: 'queued' } },
52
+ { ok: true, json: { status: 'done', run_id: 'run-2', started_at: null, completed_at: null, error_log: null } },
53
+ ]);
54
+ vi.stubGlobal('fetch', fetchSpy);
55
+ const promise = cloudRunCommand({ project: 'org/repo', branch: 'main' });
56
+ await vi.advanceTimersByTimeAsync(5000);
57
+ await promise;
58
+ expect(process.exitCode).toBe(0);
59
+ });
60
+ it('exits 1 when the job reaches failed', async () => {
61
+ const fetchSpy = mockFetchSequence([
62
+ { ok: true, json: { job_id: 'job-3', status: 'queued' } },
63
+ {
64
+ ok: true,
65
+ json: { status: 'failed', run_id: 'run-3', started_at: null, completed_at: null, error_log: 'boom' },
66
+ },
67
+ ]);
68
+ vi.stubGlobal('fetch', fetchSpy);
69
+ const promise = cloudRunCommand({ project: 'org/repo', branch: 'main' });
70
+ await vi.advanceTimersByTimeAsync(5000);
71
+ await promise;
72
+ expect(process.exitCode).toBe(1);
73
+ });
74
+ it('exits 1 when the trigger request itself fails', async () => {
75
+ const fetchSpy = mockFetchSequence([{ ok: false, status: 401, json: { error: 'Invalid PAT' } }]);
76
+ vi.stubGlobal('fetch', fetchSpy);
77
+ await cloudRunCommand({ project: 'org/repo', branch: 'main' });
78
+ expect(process.exitCode).toBe(1);
79
+ });
80
+ });
81
+ describe('parseTimeoutMs', () => {
82
+ it('parses seconds, minutes, and hours', () => {
83
+ expect(parseTimeoutMs('30s')).toBe(30_000);
84
+ expect(parseTimeoutMs('30m')).toBe(30 * 60_000);
85
+ expect(parseTimeoutMs('2h')).toBe(2 * 3_600_000);
86
+ });
87
+ it('defaults to minutes when no unit is given', () => {
88
+ expect(parseTimeoutMs('10')).toBe(10 * 60_000);
89
+ });
90
+ it('falls back to 30m for unparseable input', () => {
91
+ expect(parseTimeoutMs('nonsense')).toBe(30 * 60_000);
92
+ });
93
+ });
@@ -146,10 +146,10 @@ describe('End-to-End (E2E) Test Plan: Native Orchestrator Execution (docs/v2/cor
146
146
  // Inject a failing step / invalid selector in a new test case
147
147
  const failingDir = path.join(tmpDir, 'specs', 'Playground', 'TC-0099-failing');
148
148
  fs.mkdirSync(failingDir, { recursive: true });
149
- fs.writeFileSync(path.join(failingDir, 'web.test.ts'), `it("should fail when element does not exist", async () => {
150
- await Step.verifyPlaygroundState();
151
- await $("#non-existent-button-999").shouldBeVisible();
152
- });
149
+ fs.writeFileSync(path.join(failingDir, 'web.test.ts'), `it("should fail when element does not exist", async () => {
150
+ await Step.verifyPlaygroundState();
151
+ await $("#non-existent-button-999").shouldBeVisible();
152
+ });
153
153
  `, 'utf-8');
154
154
  // Mock exit to prevent process termination during unit test assertion
155
155
  const exitSpy = vi.spyOn(process, 'exit').mockImplementation((() => { }));
@@ -166,13 +166,13 @@ describe('End-to-End (E2E) Test Plan: Native Orchestrator Execution (docs/v2/cor
166
166
  // 1. Test a valid spec using pure Spectra static commands
167
167
  const spectraStaticDir = path.join(tmpDir, 'specs', 'Playground', 'TC-0100-spectra-static');
168
168
  fs.mkdirSync(spectraStaticDir, { recursive: true });
169
- fs.writeFileSync(path.join(spectraStaticDir, 'web.test.ts'), `it("should execute via unified Spectra static object", async () => {
170
- await Spectra.navigate("/#playground");
171
- await Spectra.type("#demo-email-input-pg", "automated@spectra.dev");
172
- await Spectra.get("#demo-email-input-pg").shouldHaveValue("automated@spectra.dev");
173
- await Spectra.wait(50);
174
- await Spectra.getAll(".demo-product-item").shouldHaveLengthGreaterThan(0);
175
- });
169
+ fs.writeFileSync(path.join(spectraStaticDir, 'web.test.ts'), `it("should execute via unified Spectra static object", async () => {
170
+ await Spectra.navigate("/#playground");
171
+ await Spectra.type("#demo-email-input-pg", "automated@spectra.dev");
172
+ await Spectra.get("#demo-email-input-pg").shouldHaveValue("automated@spectra.dev");
173
+ await Spectra.wait(50);
174
+ await Spectra.getAll(".demo-product-item").shouldHaveLengthGreaterThan(0);
175
+ });
176
176
  `, 'utf-8');
177
177
  await runCommand(['specs/Playground/TC-0100-spectra-static/web.test.ts'], { target: 'web', demo: true });
178
178
  const resultStatic = JSON.parse(fs.readFileSync(path.join(tmpDir, '.testspectra', 'reports', 'result.json'), 'utf-8'));
@@ -181,11 +181,11 @@ describe('End-to-End (E2E) Test Plan: Native Orchestrator Execution (docs/v2/cor
181
181
  // 2. Test that assertion mismatch on existing element strictly FAILS (no false positive)
182
182
  const mismatchDir = path.join(tmpDir, 'specs', 'Playground', 'TC-0101-mismatch');
183
183
  fs.mkdirSync(mismatchDir, { recursive: true });
184
- fs.writeFileSync(path.join(mismatchDir, 'web.test.ts'), `it("should strictly fail when assertion text does not match", async () => {
185
- await Spectra.navigate("/#playground");
186
- // Element exists, but text is wrong -> MUST throw and fail
187
- await Spectra.get("#demo-email-input-pg").shouldHaveValue("completely_wrong_value_xyz");
188
- });
184
+ fs.writeFileSync(path.join(mismatchDir, 'web.test.ts'), `it("should strictly fail when assertion text does not match", async () => {
185
+ await Spectra.navigate("/#playground");
186
+ // Element exists, but text is wrong -> MUST throw and fail
187
+ await Spectra.get("#demo-email-input-pg").shouldHaveValue("completely_wrong_value_xyz");
188
+ });
189
189
  `, 'utf-8');
190
190
  const exitSpy = vi.spyOn(process, 'exit').mockImplementation((() => { }));
191
191
  await runCommand(['specs/Playground/TC-0101-mismatch/web.test.ts'], { target: 'web', demo: true });
@@ -375,39 +375,39 @@ describe('End-to-End (E2E) Test Plan: Native Orchestrator Execution (docs/v2/cor
375
375
  it('E2E-10: Spectra.intercept FIFO respondOnce sequential polling and abort simulation in real Chromium', async () => {
376
376
  const fifoAbortDir = path.join(tmpDir, 'specs', 'ApiInterception', 'TC-0010-fifo-abort');
377
377
  fs.mkdirSync(fifoAbortDir, { recursive: true });
378
- fs.writeFileSync(path.join(fifoAbortDir, 'web.test.ts'), `it("should handle FIFO respondOnce queue and abort simulation", async () => {
379
- await MatchersPage.open("api-fetch");
380
-
381
- // Setup intercept with default fallback and FIFO queue
382
- const mock = await Spectra.intercept("api/posts", "GET", [
383
- { id: 999, title: "Default Fallback Post" }
384
- ]);
385
-
386
- await mock.respondOnce([
387
- { id: 101, title: "FIFO Queued Post #1" }
388
- ]);
389
- await mock.respondOnce([
390
- { id: 102, title: "FIFO Queued Post #2" }
391
- ]);
392
-
393
- // 1. First fetch triggers FIFO item #1
394
- await MatchersPage.fetchApiButton.click();
395
- await MatchersPage.fetchedItems.first().shouldContainText("FIFO Queued Post #1");
396
-
397
- // 2. Second fetch triggers FIFO item #2
398
- await MatchersPage.fetchApiButton.click();
399
- await MatchersPage.fetchedItems.first().shouldContainText("FIFO Queued Post #2");
400
-
401
- // 3. Third fetch falls back to default response
402
- await MatchersPage.fetchApiButton.click();
403
- await MatchersPage.fetchedItems.first().shouldContainText("Default Fallback Post");
404
-
405
- // 4. Test abort simulation
406
- await mock.abort("Failed");
407
- await MatchersPage.fetchApiButton.click();
408
- // On network failure, demo app shows fallback 200 OK from catch block
409
- await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK");
410
- });
378
+ fs.writeFileSync(path.join(fifoAbortDir, 'web.test.ts'), `it("should handle FIFO respondOnce queue and abort simulation", async () => {
379
+ await MatchersPage.open("api-fetch");
380
+
381
+ // Setup intercept with default fallback and FIFO queue
382
+ const mock = await Spectra.intercept("api/posts", "GET", [
383
+ { id: 999, title: "Default Fallback Post" }
384
+ ]);
385
+
386
+ await mock.respondOnce([
387
+ { id: 101, title: "FIFO Queued Post #1" }
388
+ ]);
389
+ await mock.respondOnce([
390
+ { id: 102, title: "FIFO Queued Post #2" }
391
+ ]);
392
+
393
+ // 1. First fetch triggers FIFO item #1
394
+ await MatchersPage.fetchApiButton.click();
395
+ await MatchersPage.fetchedItems.first().shouldContainText("FIFO Queued Post #1");
396
+
397
+ // 2. Second fetch triggers FIFO item #2
398
+ await MatchersPage.fetchApiButton.click();
399
+ await MatchersPage.fetchedItems.first().shouldContainText("FIFO Queued Post #2");
400
+
401
+ // 3. Third fetch falls back to default response
402
+ await MatchersPage.fetchApiButton.click();
403
+ await MatchersPage.fetchedItems.first().shouldContainText("Default Fallback Post");
404
+
405
+ // 4. Test abort simulation
406
+ await mock.abort("Failed");
407
+ await MatchersPage.fetchApiButton.click();
408
+ // On network failure, demo app shows fallback 200 OK from catch block
409
+ await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK");
410
+ });
411
411
  `, 'utf-8');
412
412
  await runCommand(['specs/ApiInterception/TC-0010-fifo-abort/web.test.ts'], { target: 'web' });
413
413
  const resultJsonPath = path.join(tmpDir, '.testspectra', 'reports', 'result.json');
@@ -289,6 +289,7 @@ export async function addCommand(moduleNameArg, options = {}) {
289
289
  copyRecursive(sampleE2eSrc, targetE2eDir, {
290
290
  'playground-e2e': e2eProjectName,
291
291
  'packages/playground/e2e': path.relative(rootDir, targetE2eDir).replace(/\\/g, '/'),
292
+ 'testspectra:scope:playground': `testspectra:scope:${featureName}`,
292
293
  'scope:playground': `scope:${featureName}`,
293
294
  });
294
295
  // Adjust project.json
@@ -300,7 +301,7 @@ export async function addCommand(moduleNameArg, options = {}) {
300
301
  pObj.sourceRoot = path.relative(rootDir, targetE2eDir).replace(/\\/g, '/');
301
302
  pObj.targets.e2e.options.cwd = path.relative(rootDir, targetE2eDir).replace(/\\/g, '/');
302
303
  pObj.targets['type-check'].options.cwd = '.';
303
- pObj.tags = [`scope:${featureName}`, 'type:e2e'];
304
+ pObj.tags = ['testspectra:e2e', `testspectra:scope:${featureName}`];
304
305
  fs.writeFileSync(projJsonPath, JSON.stringify(pObj, null, 2), 'utf-8');
305
306
  }
306
307
  catch { }
@@ -0,0 +1,13 @@
1
+ export interface CloudRunOptions {
2
+ project: string;
3
+ projectName?: string;
4
+ branch?: string;
5
+ commit?: string;
6
+ platform?: string;
7
+ wait?: boolean;
8
+ timeout?: string;
9
+ demo?: boolean;
10
+ baseUrl?: string;
11
+ }
12
+ export declare function parseTimeoutMs(timeout: string): number;
13
+ export declare function cloudRunCommand(options: CloudRunOptions): Promise<void>;
@@ -0,0 +1,120 @@
1
+ import { execFileSync } from 'child_process';
2
+ import chalk from 'chalk';
3
+ import ora from 'ora';
4
+ const POLL_INTERVAL_MS = 5000;
5
+ const DEFAULT_TIMEOUT = '30m';
6
+ function detectGitRef(...args) {
7
+ try {
8
+ return execFileSync('git', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || undefined;
9
+ }
10
+ catch {
11
+ return undefined;
12
+ }
13
+ }
14
+ export function parseTimeoutMs(timeout) {
15
+ const match = /^(\d+)(s|m|h)?$/.exec(timeout.trim());
16
+ if (!match)
17
+ return 30 * 60 * 1000;
18
+ const value = Number(match[1]);
19
+ const unit = match[2] ?? 'm';
20
+ const multiplier = unit === 's' ? 1000 : unit === 'h' ? 3_600_000 : 60_000;
21
+ return value * multiplier;
22
+ }
23
+ // Same credential path as the trigger endpoint expects: a Gitea PAT, not the
24
+ // dashboard's OAuth2 session — a CI runner can't complete a browser redirect.
25
+ // See docs/v2/cloud/git-spec-standards-and-workflow.md.
26
+ function requireEnv(name) {
27
+ const value = process.env[name];
28
+ if (!value) {
29
+ console.error(chalk.red(`Missing required environment variable: ${name}`));
30
+ console.error(chalk.gray('Set it as a CI secret — see docs/v2/cloud/git-spec-standards-and-workflow.md'));
31
+ }
32
+ return value;
33
+ }
34
+ export async function cloudRunCommand(options) {
35
+ const spectraUrl = requireEnv('SPECTRA_URL')?.replace(/\/$/, '');
36
+ const spectraToken = requireEnv('SPECTRA_TOKEN');
37
+ if (!spectraUrl || !spectraToken) {
38
+ process.exitCode = 1;
39
+ return;
40
+ }
41
+ const branch = options.branch ?? detectGitRef('rev-parse', '--abbrev-ref', 'HEAD');
42
+ if (!branch) {
43
+ console.error(chalk.red('Could not determine branch: pass --branch or run inside a git repository.'));
44
+ process.exitCode = 1;
45
+ return;
46
+ }
47
+ const commit = options.commit ?? detectGitRef('rev-parse', 'HEAD');
48
+ const platform = options.platform ?? 'web';
49
+ const wait = options.wait !== false;
50
+ const timeout = options.timeout ?? DEFAULT_TIMEOUT;
51
+ const spinner = ora(`Triggering cloud run for ${chalk.bold(options.project)}@${branch}...`).start();
52
+ let trigger;
53
+ try {
54
+ const res = await fetch(`${spectraUrl}/api/v1/runs/trigger`, {
55
+ method: 'POST',
56
+ headers: {
57
+ 'Content-Type': 'application/json',
58
+ Authorization: `Bearer ${spectraToken}`,
59
+ },
60
+ body: JSON.stringify({
61
+ project_id: options.project,
62
+ project_name: options.projectName ?? options.project,
63
+ branch,
64
+ commit_hash: commit,
65
+ platform,
66
+ demo: options.demo ?? false,
67
+ base_url: options.baseUrl,
68
+ }),
69
+ });
70
+ if (!res.ok) {
71
+ const body = await res.json().catch(() => ({ error: res.statusText }));
72
+ throw new Error(body.error ?? `HTTP ${res.status}`);
73
+ }
74
+ trigger = (await res.json());
75
+ }
76
+ catch (err) {
77
+ spinner.fail(chalk.red(`Failed to trigger cloud run: ${err.message}`));
78
+ process.exitCode = 1;
79
+ return;
80
+ }
81
+ spinner.succeed(`Cloud run queued: ${chalk.cyan(trigger.job_id)}`);
82
+ if (!wait) {
83
+ console.log(chalk.gray(`Not waiting for result. Poll ${spectraUrl}/api/v1/jobs/${trigger.job_id}/status yourself.`));
84
+ return;
85
+ }
86
+ await waitForJob(spectraUrl, spectraToken, trigger.job_id, timeout);
87
+ }
88
+ async function waitForJob(spectraUrl, spectraToken, jobId, timeout) {
89
+ const spinner = ora('Waiting for run to finish...').start();
90
+ const deadline = Date.now() + parseTimeoutMs(timeout);
91
+ while (Date.now() < deadline) {
92
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
93
+ let job;
94
+ try {
95
+ const res = await fetch(`${spectraUrl}/api/v1/jobs/${jobId}/status`, {
96
+ headers: { Authorization: `Bearer ${spectraToken}` },
97
+ });
98
+ if (!res.ok)
99
+ throw new Error(`HTTP ${res.status}`);
100
+ job = (await res.json());
101
+ }
102
+ catch (err) {
103
+ spinner.text = chalk.yellow(`Poll failed, retrying: ${err.message}`);
104
+ continue;
105
+ }
106
+ if (job.status === 'done') {
107
+ spinner.succeed(chalk.green(`Run passed (run_id: ${job.run_id})`));
108
+ process.exitCode = 0;
109
+ return;
110
+ }
111
+ if (job.status === 'failed') {
112
+ spinner.fail(chalk.red(`Run failed (run_id: ${job.run_id})${job.error_log ? `: ${job.error_log}` : ''}`));
113
+ process.exitCode = 1;
114
+ return;
115
+ }
116
+ spinner.text = `Run status: ${job.status}`;
117
+ }
118
+ spinner.fail(chalk.red(`Timed out after ${timeout} waiting for the run to finish.`));
119
+ process.exitCode = 1;
120
+ }
@@ -32,6 +32,7 @@ export async function devicesCommand(options = {}) {
32
32
  cwd,
33
33
  env: getRunnerEnv(),
34
34
  stdio: 'inherit',
35
+ windowsHide: true,
35
36
  });
36
37
  child.on('close', (code) => {
37
38
  if (code === 0) {
@@ -0,0 +1,4 @@
1
+ export interface DocsCommandOptions {
2
+ cwd?: string;
3
+ }
4
+ export declare function docsUpdateCommand(options?: DocsCommandOptions): void;
@@ -0,0 +1,17 @@
1
+ import path from 'path';
2
+ import chalk from 'chalk';
3
+ import * as p from '@clack/prompts';
4
+ import { generateArchitectureDoc } from '../generator/architecture-doc-generator.js';
5
+ function resolveBaseDir(options = {}) {
6
+ return options.cwd ? path.resolve(options.cwd) : process.cwd();
7
+ }
8
+ export function docsUpdateCommand(options = {}) {
9
+ const cwd = resolveBaseDir(options);
10
+ const result = generateArchitectureDoc(cwd);
11
+ if (result.mode === 'nx') {
12
+ p.log.success(chalk.green(`ARCHITECTURE.md regenerated (Nx/monorepo mode, ${result.featureCount ?? 0} feature module(s) detected).`));
13
+ }
14
+ else {
15
+ p.log.success(chalk.green('ARCHITECTURE.md regenerated (standalone mode).'));
16
+ }
17
+ }
@@ -42,6 +42,7 @@ export async function doctorCommand(options = {}) {
42
42
  cwd,
43
43
  env: getRunnerEnv(),
44
44
  stdio: 'inherit',
45
+ windowsHide: true,
45
46
  });
46
47
  child.on('close', (code) => {
47
48
  if (code === 0 || options.fix) {
@@ -6,6 +6,7 @@ import chalk from 'chalk';
6
6
  import { ConfigLoader } from '../config/loader.js';
7
7
  import { TypeGenerator } from '../types/generator.js';
8
8
  import { TsConfigGenerator } from '../generator/tsconfig-generator.js';
9
+ import { generateArchitectureDoc } from '../generator/architecture-doc-generator.js';
9
10
  function parsePnpmWorkspaceGlobs(content) {
10
11
  const lines = content.split('\n');
11
12
  const globs = [];
@@ -460,6 +461,8 @@ export async function initCommand(options = {}) {
460
461
  (typeof rootPkg.devDependencies['@testspectra/matchers'] === 'string' &&
461
462
  rootPkg.devDependencies['@testspectra/matchers'].startsWith('link:')))
462
463
  rootPkg.devDependencies['@testspectra/matchers'] = cliDepVersion;
464
+ if (!rootPkg.devDependencies['nx'])
465
+ rootPkg.devDependencies['nx'] = '^20.8.4';
463
466
  if (!rootPkg.devDependencies['typescript'])
464
467
  rootPkg.devDependencies['typescript'] = '^5.4.5';
465
468
  if (!rootPkg.devDependencies['@wdio/cli'])
@@ -508,6 +511,7 @@ export async function initCommand(options = {}) {
508
511
  copyRecursive(sampleE2eSrc, targetE2eDir, {
509
512
  'playground-e2e': e2eProjectName,
510
513
  'packages/playground/e2e': path.relative(cwd, targetE2eDir).replace(/\\/g, '/'),
514
+ 'testspectra:scope:playground': `testspectra:scope:${featureName}`,
511
515
  'scope:playground': `scope:${featureName}`,
512
516
  });
513
517
  // Adjust project.json
@@ -519,7 +523,7 @@ export async function initCommand(options = {}) {
519
523
  pObj.sourceRoot = path.relative(cwd, targetE2eDir).replace(/\\/g, '/');
520
524
  pObj.targets.e2e.options.cwd = path.relative(cwd, targetE2eDir).replace(/\\/g, '/');
521
525
  pObj.targets['type-check'].options.cwd = '.';
522
- pObj.tags = [`scope:${featureName}`, 'type:e2e'];
526
+ pObj.tags = ['testspectra:e2e', `testspectra:scope:${featureName}`];
523
527
  fs.writeFileSync(projJsonPath, JSON.stringify(pObj, null, 2), 'utf-8');
524
528
  }
525
529
  catch { }
@@ -557,137 +561,7 @@ export async function initCommand(options = {}) {
557
561
  // 7. Generate Ambient Types in ROOT only
558
562
  TypeGenerator.writeDeclarationFiles(cwd);
559
563
  ensureVsCodeExtensions(cwd);
560
- const archDocContent = `# TestSpectra Enterprise Monorepo Architecture
561
-
562
- This workspace uses TestSpectra's **"Centralized Configuration, Distributed Implementation"** model for automated cross-platform testing.
563
-
564
- ---
565
-
566
- ## 1. Directory & File Overview
567
-
568
- ### Centralized Root Elements
569
- - \`./spectra.config.ts\`: Single source of truth for runtime configurations (Base URL, Appium devices, browser targets, timeouts).
570
- - \`./.testspectra/\`: Local test project cache, runtime metadata, auto-generated master TSConfig (\`.testspectra/tsconfig.json\`), platform sub-configs (\`.testspectra/tsconfig/\`), and universal ambient types (\`.testspectra/types/\`). Global binaries and drivers are managed at \`~/.testspectra/drivers/\`.
571
- - \`./nx.json\`: Nx target defaults with execution caching and inputs.
572
- - \`./pnpm-workspace.yaml\`: Monorepo package glob definitions.
573
- - \`./tsconfig.json\`: Solution-style TypeScript orchestrator referencing \`./.testspectra/tsconfig.json\`.
574
-
575
- ### Centralized Shared Testing Library (\`./${sharedTestingRelPath}\`)
576
- Provides cross-feature reusable test entities with **100% zero-import global resolution**:
577
- - \`page-objects/\`: Shared Page Object models (e.g. NavigationBar, AppHeader).
578
- - \`steps/\`: Cross-feature business step flows (e.g. \`Step.loginAsAdmin()\`).
579
- - \`actions/\`: Custom atomic actions (e.g. \`Spectra.dismissBanner()\`).
580
- - \`fixtures/\`: Common test data and environment configurations (e.g. \`Fixture.appConfig\`).
581
-
582
- ### Distributed Feature E2E Modules (${featureE2eDirs.length} Features)
583
- ${featureE2eDirs
584
- .map((d) => {
585
- const rel = path.relative(cwd, d);
586
- const name = path.basename(path.dirname(d));
587
- const e2eName = `${name}-${e2eFolderName}`;
588
- return `- \`./${rel}\` (**${name}**, Nx Project: \`${e2eName}\`):
589
- - \`specs/\`: Feature test cases (\`specs/<SuiteName>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
590
- - \`page-objects/\`: Feature-specific Page Objects (e.g. \`LoginPage\`, \`ProductPage\`).
591
- - \`project.json\`: Nx targets (\`e2e\`, \`type-check\`) supporting configurations (\`--configuration=android\`, \`--configuration=ios\`, \`--configuration=headless\`).`;
592
- })
593
- .join('\n')}
594
-
595
- ---
596
-
597
- ## 2. Zero-Import Consumption Flow & Mechanics
598
-
599
- TestSpectra completely eliminates boilerplate \`import\` statements across all test specs, steps, and page objects.
600
-
601
- ### How It Works:
602
- 1. **Centralized Ambient Aggregation**:
603
- TestSpectra Language Service Plugin & CLI automatically scan:
604
- - **Local Feature Entities**: \`<feature>/${e2eFolderName}/page-objects/\`, \`<feature>/${e2eFolderName}/steps/\`, \`<feature>/${e2eFolderName}/actions/\`
605
- - **Shared Library Entities**: \`./${sharedTestingRelPath}/page-objects/\`, \`./${sharedTestingRelPath}/steps/\`, \`./${sharedTestingRelPath}/actions/\`, \`./${sharedTestingRelPath}/fixtures/\`
606
- 2. **Ambient Typing Generation**:
607
- These are compiled into \`.testspectra/types/web.d.ts\`, \`android.d.ts\`, \`ios.d.ts\`, \`fixtures.d.ts\`.
608
- 3. **Instant IDE Autocomplete & Zero Clutter**:
609
- Specs consume both local feature objects and shared library utilities globally.
610
-
611
- ### Code Example:
612
- \`\`\`typescript
613
- // packages/features/auth/e2e/specs/Auth/TC-AUTH-01/web.test.ts
614
- // 🌟 NOTICE: 100% Zero-Import & Flat Execution! (No import statement, no describe wrapper)
615
-
616
- it("should navigate via shared header and login with local POM", async () => {
617
- // 1. Consumed from Shared Testing Library (${sharedTestingRelPath}/page-objects/NavigationBar)
618
- await NavigationBar.goToLogin();
619
-
620
- // 2. Consumed from Shared Testing Library (${sharedTestingRelPath}/steps/loginAsAdmin)
621
- await Step.loginAsAdmin();
622
-
623
- // 3. Consumed from Local Feature POM (page-objects/LoginPage)
624
- await LoginPage.flashAlert.shouldBeVisible();
625
- await LoginPage.flashAlert.shouldContainText("Welcome");
626
-
627
- // 4. Consumed from Shared Testing Library Custom Action (${sharedTestingRelPath}/actions/dismissBanner)
628
- await Spectra.dismissBanner();
629
- });
630
- \`\`\`
631
-
632
- ---
633
-
634
- ## 3. How to Run Tests
635
-
636
- You can execute tests either from the **Monorepo Root via Nx** or directly inside each **Feature Directory via CLI**:
637
-
638
- ### Option A: From Root Monorepo via Nx (Recommended for CI & Team Workflows)
639
-
640
- \`\`\`bash
641
- # 1. Run E2E for a SPECIFIC feature module (e.g. auth)
642
- pnpm nx run auth-${e2eFolderName}:e2e
643
-
644
- # 2. Run E2E for a specific feature on ANDROID or IOS
645
- pnpm nx run auth-${e2eFolderName}:e2e --configuration=android
646
- pnpm nx run auth-${e2eFolderName}:e2e --configuration=ios
647
-
648
- # 3. Run E2E for a specific feature in HEADLESS browser mode
649
- pnpm nx run auth-${e2eFolderName}:e2e --configuration=headless
650
-
651
- # 4. Run ALL feature E2E suites across the entire monorepo in parallel
652
- pnpm nx run-many -t e2e
653
-
654
- # 5. Run only E2E tests for features modified in current Git branch / PR
655
- pnpm nx affected -t e2e
656
- \`\`\`
657
-
658
- ### Option B: From Inside the Feature Directory (Direct CLI)
659
-
660
- \`\`\`bash
661
- # Navigate to the feature e2e folder
662
- cd ${featureE2eDirs.length > 0 ? path.relative(cwd, featureE2eDirs[0]).replace(/\\/g, '/') : `modules/auth/${e2eFolderName}`}
663
-
664
- # Run all specs in this feature
665
- pnpm spectra run
666
-
667
- # Run a specific test case file
668
- pnpm spectra run specs/Auth/TC-AUTH-01/web.test.ts
669
-
670
- # Target Android device or emulator
671
- pnpm spectra run --target android
672
-
673
- # Run in headed / interactive browser mode
674
- pnpm spectra run --no-headless
675
- \`\`\`
676
-
677
- ---
678
-
679
- ## 4. Type Checking & Validation
680
-
681
- \`\`\`bash
682
- # Type check all E2E projects via Nx
683
- pnpm nx run-many -t type-check
684
-
685
- # Or standard TypeScript project references build from root
686
- pnpm type-check
687
- # or: npx tsc -b
688
- \`\`\`
689
- `;
690
- fs.writeFileSync(path.join(cwd, 'ARCHITECTURE.md'), archDocContent, 'utf-8');
564
+ generateArchitectureDoc(cwd);
691
565
  // 8. Ensure root .gitignore ignores .testspectra/ and *.tsbuildinfo
692
566
  const rootGitignorePath = path.join(cwd, '.gitignore');
693
567
  const ignoreEntries = ['.testspectra/', '*.tsbuildinfo', '.nx/cache'];
@@ -741,34 +615,7 @@ pnpm type-check
741
615
  TypeGenerator.writeDeclarationFiles(cwd);
742
616
  ensureVsCodeExtensions(cwd);
743
617
  // Standalone Architecture Documentation
744
- const standaloneArchDoc = `# TestSpectra Project Architecture
745
-
746
- This project is built with the TestSpectra testing framework.
747
-
748
- ## Structure & File Map
749
- - \`./spectra.config.ts\`: Typed runner configuration.
750
- - \`./specs/\`: Layered test cases (\`specs/<Suite>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
751
- - \`./page-objects/\`: Page Object models per platform.
752
- - \`./steps/\`: Business flows accessible globally via \`Step.*\`.
753
- - \`./actions/\`: Atomic actions accessible globally via \`Spectra.*\`.
754
- - \`./fixtures/\`: JSON fixtures accessible globally via \`Fixture.*\`.
755
- - \`./global-hooks/\`: Global suite lifecycle hooks.
756
- - \`./.testspectra/\`: Auto-generated ambient typings and local runtime cache.
757
-
758
- ## Execution
759
- \`\`\`bash
760
- # Run web test suite
761
- pnpm test
762
-
763
- # Run Android / iOS
764
- pnpm spectra run --target android
765
- pnpm spectra run --target ios
766
-
767
- # Type check
768
- pnpm type-check
769
- \`\`\`
770
- `;
771
- fs.writeFileSync(path.join(cwd, 'ARCHITECTURE.md'), standaloneArchDoc, 'utf-8');
618
+ generateArchitectureDoc(cwd);
772
619
  // Safely update root README.md (do not overwrite existing content)
773
620
  const standaloneReadmePath = path.join(cwd, 'README.md');
774
621
  const standaloneArchSection = `\n## E2E Testing Architecture (TestSpectra)\n\nDetailed test architecture and folder map are documented in: \nšŸ‘‰ **[ARCHITECTURE.md](./ARCHITECTURE.md)**\n\n- **Run tests**: \`pnpm test\`\n- **Type-check**: \`pnpm type-check\`\n`;
@@ -34,6 +34,7 @@ export async function installCommand(item, options = {}) {
34
34
  cwd: workspaceRoot,
35
35
  env: runnerEnv,
36
36
  stdio: 'inherit',
37
+ windowsHide: true,
37
38
  });
38
39
  }
39
40
  else {
@@ -41,6 +42,7 @@ export async function installCommand(item, options = {}) {
41
42
  cwd,
42
43
  env: runnerEnv,
43
44
  stdio: 'inherit',
45
+ windowsHide: true,
44
46
  });
45
47
  }
46
48
  child.on('close', (code) => {
@@ -14,6 +14,7 @@ export async function licenseCommand(action = 'status', key, options = {}) {
14
14
  const child = spawn(binPath, args, {
15
15
  stdio: 'inherit',
16
16
  env: process.env,
17
+ windowsHide: true,
17
18
  });
18
19
  child.on('close', (code) => {
19
20
  if (code === 0) {