@testspectra/cli 1.1.8-rc.5 → 1.1.8-rc.6
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.
- package/README.md +47 -0
- package/bin/{testspectra-runner.exe → testspectra-runner} +0 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/commands/__tests__/run-e2e.test.js +49 -49
- package/dist/commands/init.js +148 -148
- package/dist/index.js +11 -11
- package/dist/linter/__tests__/component-test-imports.test.js +51 -51
- package/dist/linter/__tests__/spec-schema.test.js +167 -167
- package/dist/linter/schemas/spec.schema.d.ts +2 -2
- package/dist/linter/schemas/suite.schema.d.ts +4 -4
- package/dist/runner/bridge.js +43 -4
- package/package.json +35 -28
- package/templates/default/CLAUDE.md +16 -16
- package/templates/default/global-hooks/after/mobile.hook.ts +3 -3
- package/templates/default/global-hooks/after/web.hook.ts +3 -3
- package/templates/default/global-hooks/before/mobile.hook.ts +3 -3
- package/templates/default/global-hooks/before/web.hook.ts +3 -3
- package/templates/default/package.json +2 -2
- package/templates/default/page-objects/AuthPage/mobile.ts +5 -5
- package/templates/default/page-objects/AuthPage/web.ts +10 -10
- package/templates/default/page-objects/MatchersPage/mobile.ts +70 -70
- package/templates/default/page-objects/MatchersPage/web.ts +43 -43
- package/templates/default/page-objects/NavigationPage/mobile.ts +14 -14
- package/templates/default/page-objects/NavigationPage/web.ts +8 -8
- package/templates/default/page-objects/PlaygroundPage/mobile.ts +42 -42
- package/templates/default/page-objects/PlaygroundPage/web.ts +31 -31
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +53 -53
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/spec.md +19 -19
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +31 -31
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/android.test.ts +3 -3
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/common.test.ts +3 -3
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +27 -27
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/spec.md +19 -19
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +26 -26
- package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/common.test.ts +30 -30
- package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/spec.md +22 -22
- package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/common.test.ts +27 -27
- package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/spec.md +20 -20
- package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/spec.md +24 -24
- package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/web.test.ts +26 -26
- package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/spec.md +37 -37
- package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/web.test.ts +21 -21
- package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/spec.md +29 -29
- package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/web.test.ts +16 -16
- package/templates/default/specs/ApiInterception/suite.md +10 -10
- package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/common.test.ts +30 -30
- package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/spec.md +23 -23
- package/templates/default/specs/ApiSeeding/hooks/after/common.hook.ts +16 -16
- package/templates/default/specs/ApiSeeding/hooks/before/common.hook.ts +28 -28
- package/templates/default/specs/ApiSeeding/suite.md +9 -9
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/mobile.test.ts +7 -7
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/spec.md +19 -19
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/web.test.ts +9 -9
- package/templates/default/specs/Authentication/suite.md +9 -9
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +9 -9
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/spec.md +17 -17
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +19 -19
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/mobile.test.ts +17 -17
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/spec.md +28 -28
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/web.test.ts +26 -26
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/common.test.ts +26 -26
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/spec.md +19 -19
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +11 -11
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/spec.md +17 -17
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +11 -11
- package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/common.test.ts +14 -14
- package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/spec.md +21 -21
- package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/mobile.test.ts +28 -28
- package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/spec.md +29 -29
- package/templates/default/specs/DeepLink/suite.md +9 -9
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +11 -11
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/spec.md +17 -17
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +11 -11
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +29 -29
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/spec.md +19 -19
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +29 -29
- package/templates/default/specs/ElementMatchers/suite.md +10 -10
- package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -5
- package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -16
- package/templates/default/specs/EnvironmentConfig/suite.md +9 -9
- package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/mobile.test.ts +26 -26
- package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/spec.md +22 -22
- package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/mobile.test.ts +13 -13
- package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/spec.md +20 -20
- package/templates/default/specs/PermissionRationale/suite.md +9 -9
- package/templates/default/specs/Playground/TC-0001-form-controls/mobile.test.ts +6 -6
- package/templates/default/specs/Playground/TC-0001-form-controls/spec.md +18 -18
- package/templates/default/specs/Playground/TC-0001-form-controls/web.test.ts +6 -6
- package/templates/default/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +6 -6
- package/templates/default/specs/Playground/TC-0002-toggle-elements/spec.md +18 -18
- package/templates/default/specs/Playground/TC-0002-toggle-elements/web.test.ts +6 -6
- package/templates/default/spectra.config.ts +52 -52
- package/templates/default/support/actions/fillCredentials/mobile.action.ts +4 -4
- package/templates/default/support/actions/fillCredentials/web.action.ts +4 -4
- package/templates/default/support/actions/seedSession/mobile.action.ts +9 -9
- package/templates/default/support/actions/seedSession/web.action.ts +13 -13
- package/templates/default/support/steps/togglePlaygroundStates/mobile.step.ts +5 -5
- package/templates/default/support/steps/togglePlaygroundStates/web.step.ts +5 -5
- package/templates/default/support/steps/verifyPlaygroundState/mobile.step.ts +6 -6
- package/templates/default/support/steps/verifyPlaygroundState/web.step.ts +6 -6
- package/templates/nx/.nx/workspace-data/{59842386-c7c4-44ca-b2c2-20e1700bd13d.db-shm → 70094CFD-E89B-57A1-9619-2FC5F4963C54.db-shm} +0 -0
- package/templates/nx/.nx/workspace-data/{59842386-c7c4-44ca-b2c2-20e1700bd13d.db-wal → 70094CFD-E89B-57A1-9619-2FC5F4963C54.db-wal} +0 -0
- package/templates/nx/.nx/workspace-data/d/daemon.log +5489 -1737
- package/templates/nx/.nx/workspace-data/d/server-process.json +1 -1
- package/templates/nx/.nx/workspace-data/file-map.json +109 -109
- package/templates/nx/.nx/workspace-data/lockfile.hash +1 -1
- package/templates/nx/.nx/workspace-data/nx_files.nxt +0 -0
- package/templates/nx/.nx/workspace-data/parsed-lock-file.json +535 -535
- package/templates/nx/.nx/workspace-data/project-graph.json +584 -584
- package/templates/nx/CLAUDE.md +10 -10
- package/templates/nx/package.json +2 -2
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +27 -27
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +27 -27
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +24 -24
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +24 -24
- package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +19 -19
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +17 -17
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +11 -11
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +11 -11
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +29 -29
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -5
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -16
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/suite.md +9 -9
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/mobile.test.ts +3 -3
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/web.test.ts +6 -6
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +3 -3
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/web.test.ts +6 -6
- package/templates/nx/pnpm-lock.yaml +6663 -6663
- package/templates/nx/pnpm-workspace.yaml +9 -9
- package/templates/nx/shared/testing/page-objects/MatchersPage/mobile.ts +33 -33
- package/templates/nx/shared/testing/page-objects/MatchersPage/web.ts +91 -91
- package/templates/nx/shared/testing/page-objects/NavigationPage/mobile.ts +5 -5
- package/templates/nx/shared/testing/page-objects/NavigationPage/web.ts +8 -8
- package/templates/nx/shared/testing/page-objects/PlaygroundPage/mobile.ts +26 -26
- package/templates/nx/shared/testing/page-objects/PlaygroundPage/web.ts +31 -31
- package/templates/nx/shared/testing/project.json +19 -19
- package/templates/nx/shared/testing/support/actions/fillCredentials/mobile.action.ts +4 -4
- package/templates/nx/shared/testing/support/actions/fillCredentials/web.action.ts +4 -4
- package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/mobile.step.ts +3 -3
- package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/web.step.ts +5 -5
- package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/mobile.step.ts +4 -4
- package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/web.step.ts +6 -6
- package/templates/nx/spectra.config.ts +52 -52
- package/templates/react-component/.cursorrules +17 -17
- package/templates/react-component/.vscode/extensions.json +5 -5
- package/templates/react-component/CLAUDE.md +14 -14
- package/templates/react-component/README.md +69 -69
- package/templates/react-component/fixtures/component-mock.json +12 -12
- package/templates/react-component/global-hooks/after/web.hook.ts +3 -3
- package/templates/react-component/global-hooks/before/web.hook.ts +3 -3
- package/templates/react-component/package.json +27 -27
- package/templates/react-component/page-objects/BadgeComponent/web.ts +23 -23
- package/templates/react-component/page-objects/ButtonComponent/web.ts +23 -23
- package/templates/react-component/page-objects/InputComponent/web.ts +13 -13
- package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/spec.md +18 -18
- package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/web.test.tsx +11 -11
- package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/spec.md +18 -18
- package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/web.test.tsx +10 -10
- package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/spec.md +18 -18
- package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/web.test.tsx +16 -16
- package/templates/react-component/specs/BadgeComponent/suite.md +12 -12
- package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/spec.md +19 -19
- package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/web.test.tsx +28 -28
- package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/spec.md +19 -19
- package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/web.test.tsx +22 -22
- package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/spec.md +18 -18
- package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/web.test.tsx +8 -8
- package/templates/react-component/specs/ButtonComponent/suite.md +12 -12
- package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/spec.md +20 -20
- package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/web.test.tsx +28 -28
- package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/spec.md +18 -18
- package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/web.test.tsx +9 -9
- package/templates/react-component/specs/InputComponent/suite.md +12 -12
- package/templates/react-component/spectra.config.ts +27 -27
- package/templates/react-component/src/components/Badge/Badge.tsx +60 -60
- package/templates/react-component/src/components/Button/Button.tsx +57 -57
- package/templates/react-component/src/components/Input/Input.tsx +41 -41
- package/templates/react-component/src/test-utils.tsx +23 -23
- package/templates/react-component/support/actions/fillInputField/web.action.ts +9 -9
- package/templates/react-component/support/steps/verifyButtonState/web.step.ts +12 -12
- package/bin/.testspectra-runner.hash +0 -1
- /package/templates/nx/.nx/workspace-data/{59842386-c7c4-44ca-b2c2-20e1700bd13d.db → 70094CFD-E89B-57A1-9619-2FC5F4963C54.db} +0 -0
|
@@ -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');
|
package/dist/commands/init.js
CHANGED
|
@@ -557,135 +557,135 @@ export async function initCommand(options = {}) {
|
|
|
557
557
|
// 7. Generate Ambient Types in ROOT only
|
|
558
558
|
TypeGenerator.writeDeclarationFiles(cwd);
|
|
559
559
|
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)
|
|
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
583
|
${featureE2eDirs
|
|
584
584
|
.map((d) => {
|
|
585
585
|
const rel = path.relative(cwd, d);
|
|
586
586
|
const name = path.basename(path.dirname(d));
|
|
587
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\`).
|
|
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
591
|
- \`project.json\`: Nx targets (\`e2e\`, \`type-check\`) supporting configurations (\`--configuration=android\`, \`--configuration=ios\`, \`--configuration=headless\`).`;
|
|
592
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
|
-
\`\`\`
|
|
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
689
|
`;
|
|
690
690
|
fs.writeFileSync(path.join(cwd, 'ARCHITECTURE.md'), archDocContent, 'utf-8');
|
|
691
691
|
// 8. Ensure root .gitignore ignores .testspectra/ and *.tsbuildinfo
|
|
@@ -741,32 +741,32 @@ pnpm type-check
|
|
|
741
741
|
TypeGenerator.writeDeclarationFiles(cwd);
|
|
742
742
|
ensureVsCodeExtensions(cwd);
|
|
743
743
|
// 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
|
-
\`\`\`
|
|
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
770
|
`;
|
|
771
771
|
fs.writeFileSync(path.join(cwd, 'ARCHITECTURE.md'), standaloneArchDoc, 'utf-8');
|
|
772
772
|
// Safely update root README.md (do not overwrite existing content)
|
package/dist/index.js
CHANGED
|
@@ -41,13 +41,13 @@ export function createCliProgram() {
|
|
|
41
41
|
.command('install [dependency]')
|
|
42
42
|
.description('Install missing testing dependencies, browser drivers, and workspace packages')
|
|
43
43
|
.option('-f, --force', 'Force re-installation of dependencies')
|
|
44
|
-
.addHelpText('after', `
|
|
45
|
-
Examples:
|
|
46
|
-
$ spectra install Install all missing required dependencies automatically
|
|
47
|
-
$ spectra install chrome Install Google Chrome for Testing & matching Chromedriver
|
|
48
|
-
$ spectra install adb Install Google Android SDK Platform Tools (ADB)
|
|
49
|
-
$ spectra install bun Install Bun runtime
|
|
50
|
-
$ spectra install android-driver Install Spectra Android Native Driver & WDIO Service
|
|
44
|
+
.addHelpText('after', `
|
|
45
|
+
Examples:
|
|
46
|
+
$ spectra install Install all missing required dependencies automatically
|
|
47
|
+
$ spectra install chrome Install Google Chrome for Testing & matching Chromedriver
|
|
48
|
+
$ spectra install adb Install Google Android SDK Platform Tools (ADB)
|
|
49
|
+
$ spectra install bun Install Bun runtime
|
|
50
|
+
$ spectra install android-driver Install Spectra Android Native Driver & WDIO Service
|
|
51
51
|
$ spectra install wdio Install WebDriverIO core packages and matchers`)
|
|
52
52
|
.action(installCommand);
|
|
53
53
|
program
|
|
@@ -105,10 +105,10 @@ Examples:
|
|
|
105
105
|
.command('license [action] [key]')
|
|
106
106
|
.description('Manage TestSpectra commercial license (activate, status, remove)')
|
|
107
107
|
.option('--json', 'Output license details as JSON')
|
|
108
|
-
.addHelpText('after', `
|
|
109
|
-
Examples:
|
|
110
|
-
$ spectra license activate <KEY> Activate license key and auto-configure private driver registry
|
|
111
|
-
$ spectra license status Display active license organization, plan, and expiration
|
|
108
|
+
.addHelpText('after', `
|
|
109
|
+
Examples:
|
|
110
|
+
$ spectra license activate <KEY> Activate license key and auto-configure private driver registry
|
|
111
|
+
$ spectra license status Display active license organization, plan, and expiration
|
|
112
112
|
$ spectra license remove Remove locally activated license credentials`)
|
|
113
113
|
.action(licenseCommand);
|
|
114
114
|
const skills = program
|
|
@@ -14,20 +14,20 @@ const __dirname = path.dirname(__filename);
|
|
|
14
14
|
*/
|
|
15
15
|
describe('Component Test (.tsx) Import Exception', () => {
|
|
16
16
|
const tempDir = path.join(__dirname, '__temp_tsx_imports__');
|
|
17
|
-
const specFrontmatter = `---
|
|
18
|
-
id: TC-0200
|
|
19
|
-
title: Sample component test
|
|
20
|
-
priority: High
|
|
21
|
-
caseType: Positive
|
|
22
|
-
status: automated
|
|
23
|
-
coverage:
|
|
24
|
-
web: automated
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
# Sample component test
|
|
28
|
-
|
|
29
|
-
## Test Steps
|
|
30
|
-
1. Mount the component and assert it is visible.
|
|
17
|
+
const specFrontmatter = `---
|
|
18
|
+
id: TC-0200
|
|
19
|
+
title: Sample component test
|
|
20
|
+
priority: High
|
|
21
|
+
caseType: Positive
|
|
22
|
+
status: automated
|
|
23
|
+
coverage:
|
|
24
|
+
web: automated
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Sample component test
|
|
28
|
+
|
|
29
|
+
## Test Steps
|
|
30
|
+
1. Mount the component and assert it is visible.
|
|
31
31
|
`;
|
|
32
32
|
beforeEach(() => {
|
|
33
33
|
fs.mkdirSync(tempDir, { recursive: true });
|
|
@@ -39,23 +39,23 @@ coverage:
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
it('does not flag no-manual-import for ordinary component/library imports in .test.tsx', () => {
|
|
42
|
-
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import { Button } from '../../src/components/Button/Button.js';
|
|
43
|
-
import React from 'react';
|
|
44
|
-
|
|
45
|
-
it('Sample component test', async () => {
|
|
46
|
-
await Spectra.mount(<Button label="Save" />);
|
|
47
|
-
});
|
|
42
|
+
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import { Button } from '../../src/components/Button/Button.js';
|
|
43
|
+
import React from 'react';
|
|
44
|
+
|
|
45
|
+
it('Sample component test', async () => {
|
|
46
|
+
await Spectra.mount(<Button label="Save" />);
|
|
47
|
+
});
|
|
48
48
|
`);
|
|
49
49
|
const { diagnostics } = SpecLinter.validateSpecFile(path.join(tempDir, 'spec.md'));
|
|
50
50
|
const importErrors = diagnostics.filter((d) => d.code === 'testspectra/no-manual-import');
|
|
51
51
|
expect(importErrors).toHaveLength(0);
|
|
52
52
|
});
|
|
53
53
|
it('still flags no-manual-import when a .test.tsx import resolves into page-objects/', () => {
|
|
54
|
-
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import ButtonComponent from '../../page-objects/ButtonComponent/web.js';
|
|
55
|
-
|
|
56
|
-
it('Sample component test', async () => {
|
|
57
|
-
await ButtonComponent.root.shouldBeVisible();
|
|
58
|
-
});
|
|
54
|
+
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import ButtonComponent from '../../page-objects/ButtonComponent/web.js';
|
|
55
|
+
|
|
56
|
+
it('Sample component test', async () => {
|
|
57
|
+
await ButtonComponent.root.shouldBeVisible();
|
|
58
|
+
});
|
|
59
59
|
`);
|
|
60
60
|
const { diagnostics } = SpecLinter.validateSpecFile(path.join(tempDir, 'spec.md'));
|
|
61
61
|
const importErrors = diagnostics.filter((d) => d.code === 'testspectra/no-manual-import');
|
|
@@ -63,50 +63,50 @@ it('Sample component test', async () => {
|
|
|
63
63
|
expect(importErrors[0].message).toContain('page-objects');
|
|
64
64
|
});
|
|
65
65
|
it('still flags no-manual-import when a .test.tsx import resolves into support/steps/', () => {
|
|
66
|
-
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import verifyButtonState from '../../support/steps/verifyButtonState/web.step.js';
|
|
67
|
-
|
|
68
|
-
it('Sample component test', async () => {
|
|
69
|
-
await verifyButtonState('Save', true);
|
|
70
|
-
});
|
|
66
|
+
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import verifyButtonState from '../../support/steps/verifyButtonState/web.step.js';
|
|
67
|
+
|
|
68
|
+
it('Sample component test', async () => {
|
|
69
|
+
await verifyButtonState('Save', true);
|
|
70
|
+
});
|
|
71
71
|
`);
|
|
72
72
|
const { diagnostics } = SpecLinter.validateSpecFile(path.join(tempDir, 'spec.md'));
|
|
73
73
|
const importErrors = diagnostics.filter((d) => d.code === 'testspectra/no-manual-import');
|
|
74
74
|
expect(importErrors).toHaveLength(1);
|
|
75
75
|
});
|
|
76
76
|
it('still flags no-manual-import when a .test.tsx import resolves into fixtures/', () => {
|
|
77
|
-
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import users from '../../fixtures/users.json';
|
|
78
|
-
|
|
79
|
-
it('Sample component test', async () => {
|
|
80
|
-
expect(users).toBeDefined();
|
|
81
|
-
});
|
|
77
|
+
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import users from '../../fixtures/users.json';
|
|
78
|
+
|
|
79
|
+
it('Sample component test', async () => {
|
|
80
|
+
expect(users).toBeDefined();
|
|
81
|
+
});
|
|
82
82
|
`);
|
|
83
83
|
const { diagnostics } = SpecLinter.validateSpecFile(path.join(tempDir, 'spec.md'));
|
|
84
84
|
const importErrors = diagnostics.filter((d) => d.code === 'testspectra/no-manual-import');
|
|
85
85
|
expect(importErrors).toHaveLength(1);
|
|
86
86
|
});
|
|
87
87
|
it('still enforces single-it-required and no-describe-block in .test.tsx files', () => {
|
|
88
|
-
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import { Button } from '../../src/components/Button/Button.js';
|
|
89
|
-
|
|
90
|
-
describe('Button', () => {
|
|
91
|
-
it('Sample component test', async () => {
|
|
92
|
-
await Spectra.mount(<Button label="Save" />);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('Another test', async () => {
|
|
96
|
-
await Spectra.mount(<Button label="Cancel" />);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
88
|
+
fs.writeFileSync(path.join(tempDir, 'web.test.tsx'), `import { Button } from '../../src/components/Button/Button.js';
|
|
89
|
+
|
|
90
|
+
describe('Button', () => {
|
|
91
|
+
it('Sample component test', async () => {
|
|
92
|
+
await Spectra.mount(<Button label="Save" />);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('Another test', async () => {
|
|
96
|
+
await Spectra.mount(<Button label="Cancel" />);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
99
|
`);
|
|
100
100
|
const { diagnostics } = SpecLinter.validateSpecFile(path.join(tempDir, 'spec.md'));
|
|
101
101
|
expect(diagnostics.some((d) => d.code === 'testspectra/no-describe-block')).toBe(true);
|
|
102
102
|
expect(diagnostics.some((d) => d.code === 'testspectra/single-it-required')).toBe(true);
|
|
103
103
|
});
|
|
104
104
|
it('still forbids all imports (unchanged behavior) in plain .test.ts E2E specs', () => {
|
|
105
|
-
fs.writeFileSync(path.join(tempDir, 'web.test.ts'), `import { LoginPage } from '../../page-objects/LoginPage/web.js';
|
|
106
|
-
|
|
107
|
-
it('Sample component test', async () => {
|
|
108
|
-
await LoginPage.submitButton.click();
|
|
109
|
-
});
|
|
105
|
+
fs.writeFileSync(path.join(tempDir, 'web.test.ts'), `import { LoginPage } from '../../page-objects/LoginPage/web.js';
|
|
106
|
+
|
|
107
|
+
it('Sample component test', async () => {
|
|
108
|
+
await LoginPage.submitButton.click();
|
|
109
|
+
});
|
|
110
110
|
`);
|
|
111
111
|
const { diagnostics } = SpecLinter.validateSpecFile(path.join(tempDir, 'spec.md'));
|
|
112
112
|
const importErrors = diagnostics.filter((d) => d.code === 'testspectra/no-manual-import');
|