@testspectra/cli 1.0.70 → 1.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +48 -0
- package/README.md +36 -270
- package/bin/.testspectra-runner.hash +1 -0
- package/bin/spectra.js +1 -1
- package/bin/testspectra-runner +0 -0
- package/demo-app/assets/index-BhlW-eXG.css +1 -0
- package/demo-app/assets/index-DOtRypCa.js +154 -0
- package/demo-app/index.html +2 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/commands/__tests__/doctor.test.d.ts +1 -0
- package/dist/commands/__tests__/doctor.test.js +39 -0
- package/dist/commands/__tests__/init.test.d.ts +1 -0
- package/dist/commands/__tests__/init.test.js +148 -0
- package/dist/commands/__tests__/license.test.d.ts +1 -0
- package/dist/commands/__tests__/license.test.js +13 -0
- package/dist/commands/__tests__/refactor.test.d.ts +1 -0
- package/dist/commands/__tests__/refactor.test.js +64 -0
- package/dist/commands/__tests__/run-e2e.test.d.ts +1 -0
- package/dist/commands/__tests__/run-e2e.test.js +422 -0
- package/dist/commands/__tests__/run.test.d.ts +1 -0
- package/dist/commands/__tests__/run.test.js +273 -0
- package/dist/commands/__tests__/watch.test.d.ts +1 -0
- package/dist/commands/__tests__/watch.test.js +155 -0
- package/dist/commands/add.js +86 -85
- package/dist/commands/demo.js +21 -11
- package/dist/commands/devices.d.ts +14 -2
- package/dist/commands/devices.js +44 -34
- package/dist/commands/doctor.d.ts +3 -1
- package/dist/commands/doctor.js +43 -264
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +211 -196
- package/dist/commands/install.d.ts +4 -0
- package/dist/commands/install.js +59 -0
- package/dist/commands/license.d.ts +4 -0
- package/dist/commands/license.js +30 -0
- package/dist/commands/lint.d.ts +5 -0
- package/dist/commands/lint.js +55 -0
- package/dist/commands/refactor.d.ts +9 -0
- package/dist/commands/refactor.js +172 -0
- package/dist/commands/run.d.ts +23 -2
- package/dist/commands/run.js +322 -111
- package/dist/commands/skills.d.ts +9 -0
- package/dist/commands/skills.js +28 -0
- package/dist/commands/sync-types.d.ts +4 -0
- package/dist/commands/sync-types.js +15 -0
- package/dist/commands/test.d.ts +17 -0
- package/dist/commands/test.js +76 -0
- package/dist/commands/update.js +39 -43
- package/dist/commands/watch.d.ts +6 -0
- package/dist/commands/watch.js +55 -45
- package/dist/config/loader.d.ts +1 -1
- package/dist/config/loader.js +40 -25
- package/dist/config/schema.d.ts +104 -145
- package/dist/config/schema.js +36 -45
- package/dist/generator/__tests__/tsconfig-isolation.test.d.ts +1 -0
- package/dist/generator/__tests__/tsconfig-isolation.test.js +282 -0
- package/dist/generator/__tests__/type-generator.test.d.ts +1 -0
- package/dist/generator/__tests__/type-generator.test.js +386 -0
- package/dist/generator/index.d.ts +2 -0
- package/dist/generator/index.js +2 -0
- package/dist/generator/tsconfig-generator.d.ts +27 -0
- package/dist/generator/tsconfig-generator.js +419 -0
- package/dist/generator/type-generator.d.ts +59 -0
- package/dist/generator/type-generator.js +740 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +165 -51
- package/dist/lifecycle/__tests__/lifecycle-engine.test.d.ts +1 -0
- package/dist/lifecycle/__tests__/lifecycle-engine.test.js +290 -0
- package/dist/lifecycle/hook-discovery.d.ts +24 -0
- package/dist/lifecycle/hook-discovery.js +60 -0
- package/dist/lifecycle/hook-dispatcher.d.ts +34 -0
- package/dist/lifecycle/hook-dispatcher.js +190 -0
- package/dist/lifecycle/index.d.ts +3 -0
- package/dist/lifecycle/index.js +3 -0
- package/dist/lifecycle/parallel-grouping.d.ts +27 -0
- package/dist/lifecycle/parallel-grouping.js +151 -0
- package/dist/linter/__tests__/anonymous-export.test.d.ts +1 -0
- package/dist/linter/__tests__/anonymous-export.test.js +184 -0
- package/dist/linter/__tests__/component-test-imports.test.d.ts +1 -0
- package/dist/linter/__tests__/component-test-imports.test.js +115 -0
- package/dist/linter/__tests__/shared-lib-boundary.test.d.ts +1 -0
- package/dist/linter/__tests__/shared-lib-boundary.test.js +270 -0
- package/dist/linter/__tests__/spec-schema.test.d.ts +1 -0
- package/dist/linter/__tests__/spec-schema.test.js +369 -0
- package/dist/linter/__tests__/step-parity.test.d.ts +1 -0
- package/dist/linter/__tests__/step-parity.test.js +372 -0
- package/dist/linter/discovery.d.ts +30 -0
- package/dist/linter/discovery.js +249 -0
- package/dist/linter/extractor.d.ts +67 -0
- package/dist/linter/extractor.js +245 -0
- package/dist/linter/index.d.ts +7 -0
- package/dist/linter/index.js +7 -0
- package/dist/linter/parser.d.ts +24 -0
- package/dist/linter/parser.js +219 -0
- package/dist/linter/schemas/spec.schema.d.ts +83 -0
- package/dist/linter/schemas/spec.schema.js +150 -0
- package/dist/linter/schemas/suite.schema.d.ts +59 -0
- package/dist/linter/schemas/suite.schema.js +83 -0
- package/dist/linter/spec-linter.d.ts +23 -0
- package/dist/linter/spec-linter.js +630 -0
- package/dist/linter/types.d.ts +28 -0
- package/dist/linter/types.js +1 -0
- package/dist/mobile/__tests__/android-device-e2e.test.d.ts +1 -0
- package/dist/mobile/__tests__/android-device-e2e.test.js +53 -0
- package/dist/mobile/__tests__/device-pool.test.d.ts +1 -0
- package/dist/mobile/__tests__/device-pool.test.js +97 -0
- package/dist/mobile/device-pool.d.ts +23 -0
- package/dist/mobile/device-pool.js +1 -0
- package/dist/mobile/index.d.ts +1 -0
- package/dist/mobile/index.js +1 -0
- package/dist/refactor/__tests__/refactor-engine.test.d.ts +1 -0
- package/dist/refactor/__tests__/refactor-engine.test.js +873 -0
- package/dist/refactor/index.d.ts +1 -0
- package/dist/refactor/index.js +1 -0
- package/dist/refactor/refactor-engine.d.ts +50 -0
- package/dist/refactor/refactor-engine.js +587 -0
- package/dist/reporter/__tests__/semantic-formatter.test.d.ts +1 -0
- package/dist/reporter/__tests__/semantic-formatter.test.js +73 -0
- package/dist/reporter/semantic-formatter.d.ts +6 -0
- package/dist/reporter/semantic-formatter.js +206 -0
- package/dist/reporter/summary-view.d.ts +12 -0
- package/dist/reporter/summary-view.js +19 -0
- package/dist/reporter/terminal-stream.d.ts +32 -0
- package/dist/reporter/terminal-stream.js +82 -0
- package/dist/reporter/types.d.ts +2 -0
- package/dist/reporter/types.js +1 -0
- package/dist/runner/bridge.d.ts +10 -5
- package/dist/runner/bridge.js +101 -45
- package/dist/runner/reporter.d.ts +32 -2
- package/dist/runner/reporter.js +427 -13
- package/dist/server/demo.js +43 -44
- package/dist/types/generator.d.ts +1 -17
- package/dist/types/generator.js +1 -443
- package/dist/utils/__tests__/api-server.test.d.ts +1 -0
- package/dist/utils/__tests__/api-server.test.js +62 -0
- package/dist/utils/__tests__/demo-server.test.d.ts +1 -0
- package/dist/utils/__tests__/demo-server.test.js +35 -0
- package/dist/utils/api-server.d.ts +19 -0
- package/dist/utils/api-server.js +179 -0
- package/dist/utils/demo-server.d.ts +5 -0
- package/dist/utils/demo-server.js +46 -36
- package/package.json +25 -13
- package/templates/default/CLAUDE.md +12 -5
- package/templates/default/fixtures/apiData.json +24 -0
- package/templates/default/package.json +12 -3
- package/templates/default/page-objects/AuthPage/mobile.ts +5 -0
- package/templates/default/page-objects/AuthPage/web.ts +10 -0
- package/templates/default/page-objects/MatchersPage/mobile.ts +66 -17
- package/templates/default/page-objects/MatchersPage/web.ts +22 -2
- package/templates/default/page-objects/NavigationPage/mobile.ts +11 -2
- package/templates/default/page-objects/NavigationPage/web.ts +1 -1
- package/templates/default/page-objects/PlaygroundPage/mobile.ts +34 -18
- package/templates/default/page-objects/PlaygroundPage/web.ts +4 -2
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +53 -0
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/spec.md +19 -0
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +31 -0
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/android.test.ts +3 -0
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/common.test.ts +3 -0
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +27 -0
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/spec.md +19 -0
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +26 -0
- package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/common.test.ts +30 -0
- package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/spec.md +22 -0
- package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/common.test.ts +27 -0
- package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/spec.md +20 -0
- package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/spec.md +24 -0
- package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/web.test.ts +26 -0
- package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/spec.md +37 -0
- package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/web.test.ts +21 -0
- package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/spec.md +29 -0
- package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/web.test.ts +16 -0
- package/templates/default/specs/ApiInterception/suite.md +10 -0
- package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/common.test.ts +30 -0
- package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/spec.md +23 -0
- package/templates/default/specs/ApiSeeding/hooks/after/common.hook.ts +16 -0
- package/templates/default/specs/ApiSeeding/hooks/before/common.hook.ts +28 -0
- package/templates/default/specs/ApiSeeding/suite.md +9 -0
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/mobile.test.ts +7 -0
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/spec.md +19 -0
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/web.test.ts +9 -0
- package/templates/default/specs/Authentication/suite.md +9 -0
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +7 -1
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/spec.md +5 -0
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +17 -3
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/mobile.test.ts +17 -0
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/spec.md +28 -0
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/web.test.ts +26 -0
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/common.test.ts +26 -0
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/spec.md +7 -0
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +9 -1
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/spec.md +5 -0
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +9 -4
- package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/common.test.ts +14 -0
- package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/spec.md +21 -0
- package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/mobile.test.ts +28 -0
- package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/spec.md +29 -0
- package/templates/default/specs/DeepLink/suite.md +9 -0
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +9 -1
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/spec.md +5 -0
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +9 -3
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +27 -1
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/spec.md +7 -0
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +27 -6
- package/templates/default/specs/ElementMatchers/suite.md +2 -1
- package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -0
- package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -0
- package/templates/default/specs/EnvironmentConfig/suite.md +9 -0
- package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/mobile.test.ts +26 -0
- package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/spec.md +22 -0
- package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/mobile.test.ts +13 -0
- package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/spec.md +20 -0
- package/templates/default/specs/PermissionRationale/suite.md +9 -0
- package/templates/default/specs/Playground/TC-0001-form-controls/mobile.test.ts +4 -1
- package/templates/default/specs/Playground/TC-0001-form-controls/spec.md +6 -0
- package/templates/default/specs/Playground/TC-0001-form-controls/web.test.ts +4 -4
- package/templates/default/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +4 -1
- package/templates/default/specs/Playground/TC-0002-toggle-elements/spec.md +6 -0
- package/templates/default/specs/Playground/TC-0002-toggle-elements/web.test.ts +3 -3
- package/templates/default/spectra.config.ts +22 -31
- package/templates/default/support/actions/fillCredentials/mobile.action.ts +3 -3
- package/templates/default/support/actions/fillCredentials/web.action.ts +1 -1
- package/templates/default/support/actions/seedSession/mobile.action.ts +9 -0
- package/templates/default/support/actions/seedSession/web.action.ts +13 -0
- package/templates/default/support/steps/togglePlaygroundStates/mobile.step.ts +3 -1
- package/templates/default/support/steps/togglePlaygroundStates/web.step.ts +3 -3
- package/templates/default/support/steps/verifyPlaygroundState/mobile.step.ts +4 -2
- package/templates/default/support/steps/verifyPlaygroundState/web.step.ts +4 -4
- package/templates/default/tsconfig.json +3 -1
- package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db +0 -0
- package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db-shm +0 -0
- package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db-wal +0 -0
- package/templates/nx/.nx/workspace-data/d/daemon.log +5366 -0
- package/templates/nx/.nx/workspace-data/d/server-process.json +3 -0
- package/templates/nx/.nx/workspace-data/file-map.json +464 -0
- package/templates/nx/.nx/workspace-data/lockfile.hash +1 -0
- package/templates/nx/.nx/workspace-data/nx_files.nxt +0 -0
- package/templates/nx/.nx/workspace-data/parsed-lock-file.json +13485 -0
- package/templates/nx/.nx/workspace-data/project-graph.json +14389 -0
- package/templates/nx/CLAUDE.md +2 -2
- package/templates/nx/package.json +6 -4
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +27 -0
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/spec.md +12 -0
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +27 -0
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +24 -0
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/spec.md +12 -0
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +24 -0
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/suite.md +9 -0
- package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +1 -1
- package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +17 -3
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +1 -1
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +15 -5
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +1 -1
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +9 -4
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +1 -1
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +9 -3
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +1 -1
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +27 -6
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -0
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -0
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/suite.md +9 -0
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/mobile.test.ts +1 -1
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/web.test.ts +4 -4
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +1 -1
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/web.test.ts +3 -3
- package/templates/nx/pnpm-lock.yaml +6663 -0
- package/templates/nx/pnpm-workspace.yaml +2 -1
- package/templates/nx/shared/testing/fixtures/apiData.json +24 -0
- package/templates/nx/shared/testing/page-objects/MatchersPage/mobile.ts +13 -1
- package/templates/nx/shared/testing/page-objects/MatchersPage/web.ts +85 -17
- package/templates/nx/shared/testing/page-objects/NavigationPage/mobile.ts +1 -1
- package/templates/nx/shared/testing/page-objects/NavigationPage/web.ts +1 -1
- package/templates/nx/shared/testing/page-objects/PlaygroundPage/mobile.ts +1 -1
- package/templates/nx/shared/testing/page-objects/PlaygroundPage/web.ts +4 -2
- package/templates/nx/shared/testing/project.json +19 -0
- package/templates/nx/shared/testing/support/actions/fillCredentials/mobile.action.ts +1 -1
- package/templates/nx/shared/testing/support/actions/fillCredentials/web.action.ts +1 -1
- package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/mobile.step.ts +1 -1
- package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/web.step.ts +3 -3
- package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/mobile.step.ts +2 -2
- package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/web.step.ts +4 -4
- package/templates/nx/spectra.config.ts +20 -29
- package/templates/nx/tsconfig.json +3 -1
- package/templates/react-component/.cursorrules +17 -0
- package/templates/react-component/.vscode/extensions.json +5 -0
- package/templates/react-component/CLAUDE.md +14 -0
- package/templates/react-component/README.md +69 -0
- package/templates/react-component/fixtures/component-mock.json +12 -0
- package/templates/react-component/global-hooks/after/web.hook.ts +3 -0
- package/templates/react-component/global-hooks/before/web.hook.ts +3 -0
- package/templates/react-component/package.json +27 -0
- package/templates/react-component/page-objects/BadgeComponent/web.ts +23 -0
- package/templates/react-component/page-objects/ButtonComponent/web.ts +23 -0
- package/templates/react-component/page-objects/InputComponent/web.ts +13 -0
- package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/spec.md +18 -0
- package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/web.test.tsx +11 -0
- package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/spec.md +18 -0
- package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/web.test.tsx +10 -0
- package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/spec.md +18 -0
- package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/web.test.tsx +16 -0
- package/templates/react-component/specs/BadgeComponent/suite.md +12 -0
- package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/spec.md +19 -0
- package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/web.test.tsx +28 -0
- package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/spec.md +19 -0
- package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/web.test.tsx +22 -0
- package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/spec.md +18 -0
- package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/web.test.tsx +8 -0
- package/templates/react-component/specs/ButtonComponent/suite.md +12 -0
- package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/spec.md +20 -0
- package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/web.test.tsx +28 -0
- package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/spec.md +18 -0
- package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/web.test.tsx +9 -0
- package/templates/react-component/specs/InputComponent/suite.md +12 -0
- package/templates/react-component/spectra.config.ts +27 -0
- package/templates/react-component/src/components/Badge/Badge.tsx +60 -0
- package/templates/react-component/src/components/Button/Button.tsx +57 -0
- package/templates/react-component/src/components/Input/Input.tsx +41 -0
- package/templates/react-component/src/test-utils.tsx +23 -0
- package/templates/react-component/support/actions/fillInputField/web.action.ts +9 -0
- package/templates/react-component/support/steps/verifyButtonState/web.step.ts +12 -0
- package/templates/react-component/tsconfig.json +8 -0
- package/demo-app/assets/index-DAUlrHTr.css +0 -1
- package/demo-app/assets/index-DN2Kb0A8.js +0 -100
- package/dist/index.cjs +0 -101
- package/dist/plugin.cjs +0 -575
- package/dist/plugin.d.ts +0 -16
- package/dist/plugin.js +0 -184
- package/dist/step/index.d.ts +0 -6
- package/dist/step/index.js +0 -6
- package/dist/step/matchers.d.ts +0 -14
- package/dist/step/matchers.js +0 -114
- package/dist/step/proto.d.ts +0 -46
- package/dist/step/proto.js +0 -114
- package/dist/step/runner/collection.d.ts +0 -13
- package/dist/step/runner/collection.js +0 -51
- package/dist/step/runner/single.d.ts +0 -21
- package/dist/step/runner/single.js +0 -138
- package/dist/step/spectra.d.ts +0 -34
- package/dist/step/spectra.js +0 -156
- package/dist/step/types.d.ts +0 -32
- package/dist/step/types.js +0 -5
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +0 -3
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +0 -7
- package/templates/default/tsconfig.spectra.android.json +0 -46
- package/templates/default/tsconfig.spectra.ios.json +0 -46
- package/templates/default/tsconfig.spectra.json +0 -22
- package/templates/default/tsconfig.spectra.web.json +0 -53
- package/templates/nx/fixtures/playgroundData.json +0 -7
- package/templates/nx/global-hooks/after/mobile.hook.ts +0 -3
- package/templates/nx/global-hooks/after/web.hook.ts +0 -3
- package/templates/nx/global-hooks/before/mobile.hook.ts +0 -3
- package/templates/nx/global-hooks/before/web.hook.ts +0 -3
- package/templates/nx/page-objects/MatchersPage/mobile.ts +0 -21
- package/templates/nx/page-objects/MatchersPage/web.ts +0 -23
- package/templates/nx/page-objects/NavigationPage/mobile.ts +0 -5
- package/templates/nx/page-objects/NavigationPage/web.ts +0 -8
- package/templates/nx/page-objects/PlaygroundPage/mobile.ts +0 -26
- package/templates/nx/page-objects/PlaygroundPage/web.ts +0 -29
- package/templates/nx/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +0 -3
- package/templates/nx/specs/BrowserContext/TC-0007-title-and-navigation/spec.md +0 -12
- package/templates/nx/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +0 -5
- package/templates/nx/specs/BrowserContext/suite.md +0 -9
- package/templates/nx/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +0 -3
- package/templates/nx/specs/ContentMatchers/TC-0005-text-and-values/spec.md +0 -12
- package/templates/nx/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +0 -7
- package/templates/nx/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +0 -3
- package/templates/nx/specs/ContentMatchers/TC-0006-collections-and-empty/spec.md +0 -12
- package/templates/nx/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +0 -6
- package/templates/nx/specs/ContentMatchers/suite.md +0 -9
- package/templates/nx/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +0 -3
- package/templates/nx/specs/ElementMatchers/TC-0003-visibility-and-dom/spec.md +0 -12
- package/templates/nx/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +0 -5
- package/templates/nx/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +0 -3
- package/templates/nx/specs/ElementMatchers/TC-0004-states-and-attributes/spec.md +0 -12
- package/templates/nx/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +0 -8
- package/templates/nx/specs/ElementMatchers/hooks/after/mobile.hook.ts +0 -1
- package/templates/nx/specs/ElementMatchers/hooks/after/web.hook.ts +0 -1
- package/templates/nx/specs/ElementMatchers/hooks/afterEach/mobile.hook.ts +0 -1
- package/templates/nx/specs/ElementMatchers/hooks/afterEach/web.hook.ts +0 -1
- package/templates/nx/specs/ElementMatchers/hooks/before/mobile.hook.ts +0 -1
- package/templates/nx/specs/ElementMatchers/hooks/before/web.hook.ts +0 -1
- package/templates/nx/specs/ElementMatchers/hooks/beforeEach/mobile.hook.ts +0 -1
- package/templates/nx/specs/ElementMatchers/hooks/beforeEach/web.hook.ts +0 -1
- package/templates/nx/specs/ElementMatchers/suite.md +0 -9
- package/templates/nx/specs/Playground/TC-0001-form-controls/mobile.test.ts +0 -3
- package/templates/nx/specs/Playground/TC-0001-form-controls/spec.md +0 -12
- package/templates/nx/specs/Playground/TC-0001-form-controls/web.test.ts +0 -6
- package/templates/nx/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +0 -3
- package/templates/nx/specs/Playground/TC-0002-toggle-elements/spec.md +0 -12
- package/templates/nx/specs/Playground/TC-0002-toggle-elements/web.test.ts +0 -6
- package/templates/nx/specs/Playground/hooks/after/mobile.hook.ts +0 -1
- package/templates/nx/specs/Playground/hooks/after/web.hook.ts +0 -1
- package/templates/nx/specs/Playground/hooks/afterEach/mobile.hook.ts +0 -1
- package/templates/nx/specs/Playground/hooks/afterEach/web.hook.ts +0 -1
- package/templates/nx/specs/Playground/hooks/before/mobile.hook.ts +0 -1
- package/templates/nx/specs/Playground/hooks/before/web.hook.ts +0 -1
- package/templates/nx/specs/Playground/hooks/beforeEach/mobile.hook.ts +0 -1
- package/templates/nx/specs/Playground/hooks/beforeEach/web.hook.ts +0 -1
- package/templates/nx/specs/Playground/suite.md +0 -9
- package/templates/nx/support/actions/fillCredentials/mobile.action.ts +0 -4
- package/templates/nx/support/actions/fillCredentials/web.action.ts +0 -4
- package/templates/nx/support/steps/togglePlaygroundStates/mobile.step.ts +0 -3
- package/templates/nx/support/steps/togglePlaygroundStates/step.md +0 -7
- package/templates/nx/support/steps/togglePlaygroundStates/web.step.ts +0 -5
- package/templates/nx/support/steps/verifyPlaygroundState/mobile.step.ts +0 -4
- package/templates/nx/support/steps/verifyPlaygroundState/step.md +0 -7
- package/templates/nx/support/steps/verifyPlaygroundState/web.step.ts +0 -6
- package/templates/nx/tsconfig.spectra.android.json +0 -39
- package/templates/nx/tsconfig.spectra.ios.json +0 -39
- package/templates/nx/tsconfig.spectra.json +0 -25
- package/templates/nx/tsconfig.spectra.shared.json +0 -25
- package/templates/nx/tsconfig.spectra.web.json +0 -45
- /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/after/mobile.hook.ts +0 -0
- /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/after/web.hook.ts +0 -0
- /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/afterEach/mobile.hook.ts +0 -0
- /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/afterEach/web.hook.ts +0 -0
- /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/before/mobile.hook.ts +0 -0
- /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/before/web.hook.ts +0 -0
- /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/beforeEach/mobile.hook.ts +0 -0
- /package/templates/{nx/specs/BrowserContext → default/specs/ApiInterception}/hooks/beforeEach/web.hook.ts +0 -0
- /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/after/mobile.hook.ts +0 -0
- /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/after/web.hook.ts +0 -0
- /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/afterEach/mobile.hook.ts +0 -0
- /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/afterEach/web.hook.ts +0 -0
- /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/before/mobile.hook.ts +0 -0
- /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/before/web.hook.ts +0 -0
- /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/beforeEach/mobile.hook.ts +0 -0
- /package/templates/nx/{specs/ContentMatchers → packages/matchers/e2e/specs/ApiInterception}/hooks/beforeEach/web.hook.ts +0 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
5
|
+
import ts from 'typescript';
|
|
6
|
+
import { TypeGenerator, PLATFORM_HIERARCHY } from '../type-generator.js';
|
|
7
|
+
import { startWatcher } from '../../commands/watch.js';
|
|
8
|
+
import { syncTypesCommand } from '../../commands/sync-types.js';
|
|
9
|
+
describe('TypeGenerator Engine (docs/v2/cli/ambient-types-generator.md)', () => {
|
|
10
|
+
let tmpDir;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'testspectra-gen-test-'));
|
|
13
|
+
});
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
try {
|
|
16
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
17
|
+
}
|
|
18
|
+
catch { }
|
|
19
|
+
});
|
|
20
|
+
it('generates all expected .d.ts files in .testspectra/types/', () => {
|
|
21
|
+
// Setup minimal workspace
|
|
22
|
+
fs.mkdirSync(path.join(tmpDir, 'page-objects', 'LoginPage'), { recursive: true });
|
|
23
|
+
fs.writeFileSync(path.join(tmpDir, 'page-objects', 'LoginPage', 'web.ts'), 'export default class LoginPage {}');
|
|
24
|
+
fs.mkdirSync(path.join(tmpDir, 'support', 'steps', 'loginAsAdmin'), { recursive: true });
|
|
25
|
+
fs.writeFileSync(path.join(tmpDir, 'support', 'steps', 'loginAsAdmin', 'web.step.ts'), 'export default async function () {}');
|
|
26
|
+
fs.mkdirSync(path.join(tmpDir, 'support', 'actions', 'safeClick'), { recursive: true });
|
|
27
|
+
fs.writeFileSync(path.join(tmpDir, 'support', 'actions', 'safeClick', 'web.action.ts'), 'export default async function () {}');
|
|
28
|
+
fs.mkdirSync(path.join(tmpDir, 'fixtures'), { recursive: true });
|
|
29
|
+
fs.writeFileSync(path.join(tmpDir, 'fixtures', 'users.json'), JSON.stringify({ admin: { id: 1 } }));
|
|
30
|
+
TypeGenerator.generateAll(tmpDir);
|
|
31
|
+
const typesDir = path.join(tmpDir, '.testspectra', 'types');
|
|
32
|
+
expect(fs.existsSync(path.join(typesDir, 'web.d.ts'))).toBe(true);
|
|
33
|
+
expect(fs.existsSync(path.join(typesDir, 'mobile.d.ts'))).toBe(true);
|
|
34
|
+
expect(fs.existsSync(path.join(typesDir, 'android.d.ts'))).toBe(true);
|
|
35
|
+
expect(fs.existsSync(path.join(typesDir, 'ios.d.ts'))).toBe(true);
|
|
36
|
+
expect(fs.existsSync(path.join(typesDir, 'common.d.ts'))).toBe(true);
|
|
37
|
+
expect(fs.existsSync(path.join(typesDir, 'fixtures.d.ts'))).toBe(true);
|
|
38
|
+
expect(fs.existsSync(path.join(typesDir, 'index.d.ts'))).toBe(true);
|
|
39
|
+
const webDts = fs.readFileSync(path.join(typesDir, 'web.d.ts'), 'utf-8');
|
|
40
|
+
expect(webDts).toContain('declare const LoginPage:');
|
|
41
|
+
expect(webDts).toContain('"loginAsAdmin":');
|
|
42
|
+
expect(webDts).toContain('"safeClick":');
|
|
43
|
+
expect(webDts).toContain('declare const Spectra: TestSpectraActions;');
|
|
44
|
+
expect(webDts).toContain('declare const Step: TestSpectraSteps;');
|
|
45
|
+
const fixturesDts = fs.readFileSync(path.join(typesDir, 'fixtures.d.ts'), 'utf-8');
|
|
46
|
+
expect(fixturesDts).toContain('readonly users: typeof import(');
|
|
47
|
+
});
|
|
48
|
+
it('validates zero-import TypeScript test compilation with zero diagnostic errors', () => {
|
|
49
|
+
// 1. Setup workspace with real TypeScript exports
|
|
50
|
+
const poDir = path.join(tmpDir, 'page-objects', 'LoginPage');
|
|
51
|
+
fs.mkdirSync(poDir, { recursive: true });
|
|
52
|
+
fs.writeFileSync(path.join(poDir, 'web.ts'), 'export default class LoginPage {\n static username = "#user";\n static async login() {}\n}');
|
|
53
|
+
const stepDir = path.join(tmpDir, 'support', 'steps', 'loginAsAdmin');
|
|
54
|
+
fs.mkdirSync(stepDir, { recursive: true });
|
|
55
|
+
fs.writeFileSync(path.join(stepDir, 'web.step.ts'), 'export default async function (role?: string) {}');
|
|
56
|
+
const fixDir = path.join(tmpDir, 'fixtures');
|
|
57
|
+
fs.mkdirSync(fixDir, { recursive: true });
|
|
58
|
+
fs.writeFileSync(path.join(fixDir, 'users.json'), JSON.stringify({ admin: { id: 101, email: 'admin@test.local' } }));
|
|
59
|
+
// Generate declarations
|
|
60
|
+
TypeGenerator.generateAll(tmpDir);
|
|
61
|
+
const webDtsPath = path.join(tmpDir, '.testspectra', 'types', 'web.d.ts');
|
|
62
|
+
const fixturesDtsPath = path.join(tmpDir, '.testspectra', 'types', 'fixtures.d.ts');
|
|
63
|
+
// 2. Write a test file that uses ZERO imports
|
|
64
|
+
const testFilePath = path.join(tmpDir, 'specs', 'auth.test.ts');
|
|
65
|
+
fs.mkdirSync(path.dirname(testFilePath), { recursive: true });
|
|
66
|
+
fs.writeFileSync(testFilePath, `// Zero manual imports!
|
|
67
|
+
async function verifyZeroImport() {
|
|
68
|
+
const user = Fixture.users.admin.email;
|
|
69
|
+
const selector = LoginPage.username;
|
|
70
|
+
await LoginPage.login();
|
|
71
|
+
await Step.loginAsAdmin("superadmin");
|
|
72
|
+
}
|
|
73
|
+
`);
|
|
74
|
+
// 3. Compile with TypeScript compiler API
|
|
75
|
+
const program = ts.createProgram([testFilePath, webDtsPath, fixturesDtsPath], {
|
|
76
|
+
noEmit: true,
|
|
77
|
+
target: ts.ScriptTarget.ES2022,
|
|
78
|
+
module: ts.ModuleKind.NodeNext,
|
|
79
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
80
|
+
skipLibCheck: true,
|
|
81
|
+
strict: true,
|
|
82
|
+
});
|
|
83
|
+
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
84
|
+
const relevantErrors = diagnostics.filter((d) => d.file?.fileName === testFilePath);
|
|
85
|
+
expect(relevantErrors.length).toBe(0);
|
|
86
|
+
});
|
|
87
|
+
it('enforces common.d.ts contains only universal common symbols and fixtures', () => {
|
|
88
|
+
// Create web-specific Page Object and common-specific Page Object
|
|
89
|
+
fs.mkdirSync(path.join(tmpDir, 'page-objects', 'WebOnlyPage'), { recursive: true });
|
|
90
|
+
fs.writeFileSync(path.join(tmpDir, 'page-objects', 'WebOnlyPage', 'web.ts'), 'export default class WebOnlyPage {}');
|
|
91
|
+
fs.mkdirSync(path.join(tmpDir, 'page-objects', 'CommonPage'), { recursive: true });
|
|
92
|
+
fs.writeFileSync(path.join(tmpDir, 'page-objects', 'CommonPage', 'common.ts'), 'export default class CommonPage {}');
|
|
93
|
+
// Create web-specific step and common step
|
|
94
|
+
fs.mkdirSync(path.join(tmpDir, 'support', 'steps', 'webStep'), { recursive: true });
|
|
95
|
+
fs.writeFileSync(path.join(tmpDir, 'support', 'steps', 'webStep', 'web.step.ts'), 'export default async function () {}');
|
|
96
|
+
fs.mkdirSync(path.join(tmpDir, 'support', 'steps', 'commonStep'), { recursive: true });
|
|
97
|
+
fs.writeFileSync(path.join(tmpDir, 'support', 'steps', 'commonStep', 'common.step.ts'), 'export default async function () {}');
|
|
98
|
+
TypeGenerator.generateAll(tmpDir);
|
|
99
|
+
const commonDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'common.d.ts'), 'utf-8');
|
|
100
|
+
// Must contain common
|
|
101
|
+
expect(commonDts).toContain('CommonPage');
|
|
102
|
+
expect(commonDts).toContain('commonStep');
|
|
103
|
+
// Must NOT contain web-only symbols
|
|
104
|
+
expect(commonDts).not.toContain('WebOnlyPage');
|
|
105
|
+
expect(commonDts).not.toContain('webStep');
|
|
106
|
+
});
|
|
107
|
+
it('strictly enforces platform inheritance across Android, iOS, Mobile, Web, and Common', () => {
|
|
108
|
+
expect(PLATFORM_HIERARCHY.web).toEqual(['web', 'common']);
|
|
109
|
+
expect(PLATFORM_HIERARCHY.android).toEqual(['android', 'mobile', 'common']);
|
|
110
|
+
expect(PLATFORM_HIERARCHY.ios).toEqual(['ios', 'mobile', 'common']);
|
|
111
|
+
expect(PLATFORM_HIERARCHY.mobile).toEqual(['mobile', 'common']);
|
|
112
|
+
expect(PLATFORM_HIERARCHY.common).toEqual(['common']);
|
|
113
|
+
// Setup platform specific Page Objects
|
|
114
|
+
const poDir = path.join(tmpDir, 'page-objects');
|
|
115
|
+
fs.mkdirSync(path.join(poDir, 'PlatformMatrix'), { recursive: true });
|
|
116
|
+
fs.writeFileSync(path.join(poDir, 'PlatformMatrix', 'android.ts'), 'export default class AndroidPO {}');
|
|
117
|
+
fs.writeFileSync(path.join(poDir, 'PlatformMatrix', 'ios.ts'), 'export default class IosPO {}');
|
|
118
|
+
fs.writeFileSync(path.join(poDir, 'PlatformMatrix', 'web.ts'), 'export default class WebPO {}');
|
|
119
|
+
fs.mkdirSync(path.join(poDir, 'MobileOnly'), { recursive: true });
|
|
120
|
+
fs.writeFileSync(path.join(poDir, 'MobileOnly', 'mobile.ts'), 'export default class MobileOnlyPO {}');
|
|
121
|
+
TypeGenerator.generateAll(tmpDir);
|
|
122
|
+
const typesDir = path.join(tmpDir, '.testspectra', 'types');
|
|
123
|
+
const androidDts = fs.readFileSync(path.join(typesDir, 'android.d.ts'), 'utf-8');
|
|
124
|
+
const iosDts = fs.readFileSync(path.join(typesDir, 'ios.d.ts'), 'utf-8');
|
|
125
|
+
const mobileDts = fs.readFileSync(path.join(typesDir, 'mobile.d.ts'), 'utf-8');
|
|
126
|
+
const webDts = fs.readFileSync(path.join(typesDir, 'web.d.ts'), 'utf-8');
|
|
127
|
+
// Android should resolve android.js and mobile.js, but NOT web.js or ios.js
|
|
128
|
+
expect(androidDts).toContain('PlatformMatrix/android.js');
|
|
129
|
+
expect(androidDts).toContain('MobileOnly/mobile.js');
|
|
130
|
+
expect(androidDts).not.toContain('PlatformMatrix/ios.js');
|
|
131
|
+
expect(androidDts).not.toContain('PlatformMatrix/web.js');
|
|
132
|
+
// iOS should resolve ios.js and mobile.js, but NOT web.js or android.js
|
|
133
|
+
expect(iosDts).toContain('PlatformMatrix/ios.js');
|
|
134
|
+
expect(iosDts).toContain('MobileOnly/mobile.js');
|
|
135
|
+
expect(iosDts).not.toContain('PlatformMatrix/android.js');
|
|
136
|
+
expect(iosDts).not.toContain('PlatformMatrix/web.js');
|
|
137
|
+
// Mobile should resolve mobile.js, but NOT android.js, ios.js, or web.js
|
|
138
|
+
expect(mobileDts).toContain('MobileOnly/mobile.js');
|
|
139
|
+
expect(mobileDts).not.toContain('PlatformMatrix/android.js');
|
|
140
|
+
expect(mobileDts).not.toContain('PlatformMatrix/ios.js');
|
|
141
|
+
expect(mobileDts).not.toContain('PlatformMatrix/web.js');
|
|
142
|
+
// Web should resolve web.js, but NOT mobile.js, android.js, or ios.js
|
|
143
|
+
expect(webDts).toContain('PlatformMatrix/web.js');
|
|
144
|
+
expect(webDts).not.toContain('MobileOnly/mobile.js');
|
|
145
|
+
expect(webDts).not.toContain('PlatformMatrix/android.js');
|
|
146
|
+
expect(webDts).not.toContain('PlatformMatrix/ios.js');
|
|
147
|
+
});
|
|
148
|
+
it('enforces strict ambient scope: excludes raw $ and $$ from global ambient namespace', () => {
|
|
149
|
+
TypeGenerator.generateAll(tmpDir);
|
|
150
|
+
const webDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'), 'utf-8');
|
|
151
|
+
const mobileDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'mobile.d.ts'), 'utf-8');
|
|
152
|
+
// Raw $ and $$ must NOT be declared as global variables to enforce Spectra.get() / Spectra.getAll()
|
|
153
|
+
expect(webDts).not.toMatch(/declare\s+const\s+\$:/);
|
|
154
|
+
expect(webDts).not.toMatch(/declare\s+const\s+\$\$: /);
|
|
155
|
+
expect(mobileDts).not.toMatch(/declare\s+const\s+\$:/);
|
|
156
|
+
expect(mobileDts).not.toMatch(/declare\s+const\s+\$\$: /);
|
|
157
|
+
});
|
|
158
|
+
it('purges declarations when full directory is deleted', () => {
|
|
159
|
+
const stepDir = path.join(tmpDir, 'support', 'steps', 'loginAsAdmin');
|
|
160
|
+
fs.mkdirSync(stepDir, { recursive: true });
|
|
161
|
+
fs.writeFileSync(path.join(stepDir, 'web.step.ts'), 'export default async function () {}');
|
|
162
|
+
TypeGenerator.generateAll(tmpDir);
|
|
163
|
+
let webDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'), 'utf-8');
|
|
164
|
+
expect(webDts).toContain('loginAsAdmin');
|
|
165
|
+
// Delete entire step folder
|
|
166
|
+
fs.rmSync(stepDir, { recursive: true, force: true });
|
|
167
|
+
TypeGenerator.generateAll(tmpDir);
|
|
168
|
+
webDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'), 'utf-8');
|
|
169
|
+
expect(webDts).not.toContain('loginAsAdmin');
|
|
170
|
+
});
|
|
171
|
+
it('handles partial platform file deletion: purges from web while preserving in mobile/android/ios', () => {
|
|
172
|
+
const stepDir = path.join(tmpDir, 'support', 'steps', 'loginAsAdmin');
|
|
173
|
+
fs.mkdirSync(stepDir, { recursive: true });
|
|
174
|
+
fs.writeFileSync(path.join(stepDir, 'web.step.ts'), 'export default async function () {}');
|
|
175
|
+
fs.writeFileSync(path.join(stepDir, 'mobile.step.ts'), 'export default async function () {}');
|
|
176
|
+
TypeGenerator.generateAll(tmpDir);
|
|
177
|
+
let webDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'), 'utf-8');
|
|
178
|
+
let mobileDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'mobile.d.ts'), 'utf-8');
|
|
179
|
+
let androidDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'android.d.ts'), 'utf-8');
|
|
180
|
+
let iosDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'ios.d.ts'), 'utf-8');
|
|
181
|
+
expect(webDts).toContain('loginAsAdmin');
|
|
182
|
+
expect(mobileDts).toContain('loginAsAdmin');
|
|
183
|
+
expect(androidDts).toContain('loginAsAdmin');
|
|
184
|
+
expect(iosDts).toContain('loginAsAdmin');
|
|
185
|
+
// Delete only web.step.ts
|
|
186
|
+
fs.unlinkSync(path.join(stepDir, 'web.step.ts'));
|
|
187
|
+
TypeGenerator.generateAll(tmpDir);
|
|
188
|
+
webDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'), 'utf-8');
|
|
189
|
+
mobileDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'mobile.d.ts'), 'utf-8');
|
|
190
|
+
androidDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'android.d.ts'), 'utf-8');
|
|
191
|
+
iosDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'ios.d.ts'), 'utf-8');
|
|
192
|
+
// Purged from web
|
|
193
|
+
expect(webDts).not.toContain('loginAsAdmin');
|
|
194
|
+
// Preserved in mobile, android, ios
|
|
195
|
+
expect(mobileDts).toContain('loginAsAdmin');
|
|
196
|
+
expect(androidDts).toContain('loginAsAdmin');
|
|
197
|
+
expect(iosDts).toContain('loginAsAdmin');
|
|
198
|
+
});
|
|
199
|
+
it('falls back to common.ts when web.ts is deleted inside page object folder', () => {
|
|
200
|
+
const poDir = path.join(tmpDir, 'page-objects', 'LoginPage');
|
|
201
|
+
fs.mkdirSync(poDir, { recursive: true });
|
|
202
|
+
fs.writeFileSync(path.join(poDir, 'web.ts'), 'export default class LoginPageWeb {}');
|
|
203
|
+
fs.writeFileSync(path.join(poDir, 'common.ts'), 'export default class LoginPageCommon {}');
|
|
204
|
+
TypeGenerator.generateAll(tmpDir);
|
|
205
|
+
let webDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'), 'utf-8');
|
|
206
|
+
expect(webDts).toContain('LoginPage/web.js');
|
|
207
|
+
// Delete web.ts, leaving common.ts
|
|
208
|
+
fs.unlinkSync(path.join(poDir, 'web.ts'));
|
|
209
|
+
TypeGenerator.generateAll(tmpDir);
|
|
210
|
+
webDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'), 'utf-8');
|
|
211
|
+
// Still declared, gracefully falling back to common.js
|
|
212
|
+
expect(webDts).toContain('declare const LoginPage:');
|
|
213
|
+
expect(webDts).toContain('LoginPage/common.js');
|
|
214
|
+
});
|
|
215
|
+
it('manages fixture file lifecycle for json, yaml, and csv files', () => {
|
|
216
|
+
const fixturesDir = path.join(tmpDir, 'fixtures');
|
|
217
|
+
fs.mkdirSync(fixturesDir, { recursive: true });
|
|
218
|
+
fs.writeFileSync(path.join(fixturesDir, 'users.json'), JSON.stringify({ user1: 'test' }));
|
|
219
|
+
fs.writeFileSync(path.join(fixturesDir, 'config.yaml'), 'env: production\n');
|
|
220
|
+
fs.writeFileSync(path.join(fixturesDir, 'dataset.csv'), 'id,name\n1,Alpha\n');
|
|
221
|
+
TypeGenerator.generateAll(tmpDir);
|
|
222
|
+
let fixturesDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'fixtures.d.ts'), 'utf-8');
|
|
223
|
+
expect(fixturesDts).toContain('readonly users: typeof import(');
|
|
224
|
+
expect(fixturesDts).toContain('readonly config: string;');
|
|
225
|
+
expect(fixturesDts).toContain('readonly dataset: string;');
|
|
226
|
+
// Rename fixtures/users.json to fixtures/accounts.json
|
|
227
|
+
fs.renameSync(path.join(fixturesDir, 'users.json'), path.join(fixturesDir, 'accounts.json'));
|
|
228
|
+
TypeGenerator.generateAll(tmpDir);
|
|
229
|
+
fixturesDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'fixtures.d.ts'), 'utf-8');
|
|
230
|
+
expect(fixturesDts).not.toContain('readonly users:');
|
|
231
|
+
expect(fixturesDts).toContain('readonly accounts:');
|
|
232
|
+
// Delete accounts.json and dataset.csv
|
|
233
|
+
fs.unlinkSync(path.join(fixturesDir, 'accounts.json'));
|
|
234
|
+
fs.unlinkSync(path.join(fixturesDir, 'dataset.csv'));
|
|
235
|
+
TypeGenerator.generateAll(tmpDir);
|
|
236
|
+
fixturesDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'fixtures.d.ts'), 'utf-8');
|
|
237
|
+
expect(fixturesDts).not.toContain('readonly accounts:');
|
|
238
|
+
expect(fixturesDts).not.toContain('readonly dataset:');
|
|
239
|
+
expect(fixturesDts).toContain('readonly config: string;');
|
|
240
|
+
});
|
|
241
|
+
it('executes spectra sync-types CLI command directly', async () => {
|
|
242
|
+
fs.mkdirSync(path.join(tmpDir, 'page-objects', 'CartPage'), { recursive: true });
|
|
243
|
+
fs.writeFileSync(path.join(tmpDir, 'page-objects', 'CartPage', 'web.ts'), 'export default class CartPage {}');
|
|
244
|
+
await syncTypesCommand({ cwd: tmpDir });
|
|
245
|
+
const webDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'), 'utf-8');
|
|
246
|
+
expect(webDts).toContain('declare const CartPage:');
|
|
247
|
+
});
|
|
248
|
+
it('updates declarations via watcher in debounced manner within <= 100ms', async () => {
|
|
249
|
+
const fixturesDir = path.join(tmpDir, 'fixtures');
|
|
250
|
+
fs.mkdirSync(fixturesDir, { recursive: true });
|
|
251
|
+
const handle = startWatcher(tmpDir, 30);
|
|
252
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
253
|
+
try {
|
|
254
|
+
// Add a fixture
|
|
255
|
+
fs.writeFileSync(path.join(fixturesDir, 'products.json'), JSON.stringify({ item: 1 }));
|
|
256
|
+
const start = Date.now();
|
|
257
|
+
let found = false;
|
|
258
|
+
while (Date.now() - start < 2000) {
|
|
259
|
+
try {
|
|
260
|
+
const fixturesDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'fixtures.d.ts'), 'utf-8');
|
|
261
|
+
if (fixturesDts.includes('readonly products:')) {
|
|
262
|
+
found = true;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch { }
|
|
267
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
268
|
+
}
|
|
269
|
+
expect(found).toBe(true);
|
|
270
|
+
const fixturesDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'fixtures.d.ts'), 'utf-8');
|
|
271
|
+
expect(fixturesDts).toContain('readonly products:');
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
handle.close();
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
it('discovers custom shared library directory configured in tsconfig.spectra.shared.json', () => {
|
|
278
|
+
const customSharedDir = path.join(tmpDir, 'libs', 'shared-e2e');
|
|
279
|
+
fs.mkdirSync(path.join(customSharedDir, 'page-objects', 'SharedNav'), { recursive: true });
|
|
280
|
+
fs.writeFileSync(path.join(customSharedDir, 'page-objects', 'SharedNav', 'common.ts'), 'export default class SharedNav {}');
|
|
281
|
+
// Write tsconfig.spectra.shared.json pointing to custom libs/shared-e2e
|
|
282
|
+
fs.writeFileSync(path.join(tmpDir, 'tsconfig.spectra.shared.json'), JSON.stringify({
|
|
283
|
+
include: ['.testspectra/types/shared/common.d.ts', 'libs/shared-e2e/**/*.ts'],
|
|
284
|
+
}), 'utf-8');
|
|
285
|
+
const scopes = TypeGenerator.getEntityScopes(tmpDir);
|
|
286
|
+
const sharedScope = scopes.find((s) => s.isShared);
|
|
287
|
+
expect(sharedScope).toBeDefined();
|
|
288
|
+
expect(sharedScope?.dir).toBe(path.resolve(customSharedDir));
|
|
289
|
+
TypeGenerator.generateAll(tmpDir);
|
|
290
|
+
const sharedCommonDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'shared', 'common.d.ts'), 'utf-8');
|
|
291
|
+
expect(sharedCommonDts).toContain('declare const SharedNav:');
|
|
292
|
+
});
|
|
293
|
+
it('nx monorepo: does NOT generate types from libs/ or packages/ in root scope', () => {
|
|
294
|
+
// Simulate an Nx monorepo: nx.json at root, page-objects only inside libs/shared-e2e
|
|
295
|
+
fs.writeFileSync(path.join(tmpDir, 'nx.json'), JSON.stringify({ version: 2 }), 'utf-8');
|
|
296
|
+
const libsSharedDir = path.join(tmpDir, 'libs', 'shared-e2e');
|
|
297
|
+
fs.mkdirSync(path.join(libsSharedDir, 'page-objects', 'LibPage'), { recursive: true });
|
|
298
|
+
fs.writeFileSync(path.join(libsSharedDir, 'page-objects', 'LibPage', 'common.ts'), 'export default class LibPage {}');
|
|
299
|
+
const pkgDir = path.join(tmpDir, 'packages', 'shared');
|
|
300
|
+
fs.mkdirSync(path.join(pkgDir, 'page-objects', 'PkgPage'), { recursive: true });
|
|
301
|
+
fs.writeFileSync(path.join(pkgDir, 'page-objects', 'PkgPage', 'common.ts'), 'export default class PkgPage {}');
|
|
302
|
+
// Also add a root-level page-object (should appear in root scope)
|
|
303
|
+
fs.mkdirSync(path.join(tmpDir, 'page-objects', 'RootPage'), { recursive: true });
|
|
304
|
+
fs.writeFileSync(path.join(tmpDir, 'page-objects', 'RootPage', 'common.ts'), 'export default class RootPage {}');
|
|
305
|
+
TypeGenerator.generateAll(tmpDir);
|
|
306
|
+
const rootCommonDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'common.d.ts'), 'utf-8');
|
|
307
|
+
// Root scope must contain the root-level page object
|
|
308
|
+
expect(rootCommonDts).toContain('RootPage');
|
|
309
|
+
// Root scope must NOT bleed in types from libs/ or packages/ subdirs
|
|
310
|
+
expect(rootCommonDts).not.toContain('LibPage');
|
|
311
|
+
expect(rootCommonDts).not.toContain('PkgPage');
|
|
312
|
+
});
|
|
313
|
+
it('nx monorepo: does NOT generate steps/actions from libs/ or packages/ in root scope', () => {
|
|
314
|
+
fs.writeFileSync(path.join(tmpDir, 'nx.json'), JSON.stringify({ version: 2 }), 'utf-8');
|
|
315
|
+
// Step inside libs/ — should stay in shared scope, not root scope
|
|
316
|
+
const libsStepDir = path.join(tmpDir, 'libs', 'shared-e2e', 'support', 'steps', 'sharedLogin');
|
|
317
|
+
fs.mkdirSync(libsStepDir, { recursive: true });
|
|
318
|
+
fs.writeFileSync(path.join(libsStepDir, 'common.step.ts'), 'export default async function sharedLogin() {}');
|
|
319
|
+
// Step inside packages/ — same expectation
|
|
320
|
+
const pkgStepDir = path.join(tmpDir, 'packages', 'testing', 'support', 'steps', 'pkgStep');
|
|
321
|
+
fs.mkdirSync(pkgStepDir, { recursive: true });
|
|
322
|
+
fs.writeFileSync(path.join(pkgStepDir, 'common.step.ts'), 'export default async function pkgStep() {}');
|
|
323
|
+
// Root-level step (should appear in root scope)
|
|
324
|
+
const rootStepDir = path.join(tmpDir, 'support', 'steps', 'rootLogin');
|
|
325
|
+
fs.mkdirSync(rootStepDir, { recursive: true });
|
|
326
|
+
fs.writeFileSync(path.join(rootStepDir, 'common.step.ts'), 'export default async function rootLogin() {}');
|
|
327
|
+
TypeGenerator.generateAll(tmpDir);
|
|
328
|
+
const rootCommonDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'common.d.ts'), 'utf-8');
|
|
329
|
+
// Root step is present
|
|
330
|
+
expect(rootCommonDts).toContain('rootLogin');
|
|
331
|
+
// Shared/pkg steps must NOT bleed into root scope
|
|
332
|
+
expect(rootCommonDts).not.toContain('sharedLogin');
|
|
333
|
+
expect(rootCommonDts).not.toContain('pkgStep');
|
|
334
|
+
});
|
|
335
|
+
it('does not generate features/ scope for templates/, src/, or build/ subdirectories', () => {
|
|
336
|
+
// Simulate a parent workspace that contains a templates/default/specs/ structure
|
|
337
|
+
// (e.g., when generateAll is run from cli/ which contains templates/default/)
|
|
338
|
+
const templatesDefault = path.join(tmpDir, 'templates', 'default');
|
|
339
|
+
fs.mkdirSync(path.join(templatesDefault, 'specs', 'Suite1', 'TC-001'), { recursive: true });
|
|
340
|
+
fs.writeFileSync(path.join(templatesDefault, 'specs', 'Suite1', 'TC-001', 'web.test.ts'), 'it("t", () => {});');
|
|
341
|
+
// Same for src/ and build/
|
|
342
|
+
const srcSpecs = path.join(tmpDir, 'src', 'app', 'specs');
|
|
343
|
+
fs.mkdirSync(srcSpecs, { recursive: true });
|
|
344
|
+
fs.writeFileSync(path.join(srcSpecs, 'foo.ts'), '');
|
|
345
|
+
const buildTests = path.join(tmpDir, 'build', 'tests');
|
|
346
|
+
fs.mkdirSync(buildTests, { recursive: true });
|
|
347
|
+
TypeGenerator.generateAll(tmpDir);
|
|
348
|
+
// features/default, features/app, features/build must NOT be generated
|
|
349
|
+
expect(fs.existsSync(path.join(tmpDir, '.testspectra', 'types', 'features', 'default'))).toBe(false);
|
|
350
|
+
expect(fs.existsSync(path.join(tmpDir, '.testspectra', 'types', 'features', 'app'))).toBe(false);
|
|
351
|
+
expect(fs.existsSync(path.join(tmpDir, '.testspectra', 'types', 'features', 'build'))).toBe(false);
|
|
352
|
+
});
|
|
353
|
+
it('discovers arbitrary custom shared library directory (e.g. core/testing) dynamically without candidate list', () => {
|
|
354
|
+
// Custom user folder structure: core/testing (shared) + apps/portal/e2e (feature)
|
|
355
|
+
const customShared = path.join(tmpDir, 'core', 'testing');
|
|
356
|
+
fs.mkdirSync(path.join(customShared, 'page-objects', 'CoreNav'), { recursive: true });
|
|
357
|
+
fs.writeFileSync(path.join(customShared, 'page-objects', 'CoreNav', 'common.ts'), 'export default class CoreNav {}');
|
|
358
|
+
fs.mkdirSync(path.join(customShared, 'support', 'steps', 'coreAuth'), { recursive: true });
|
|
359
|
+
fs.writeFileSync(path.join(customShared, 'support', 'steps', 'coreAuth', 'common.step.ts'), 'export default async function coreAuth() {}');
|
|
360
|
+
fs.mkdirSync(path.join(customShared, 'fixtures'), { recursive: true });
|
|
361
|
+
fs.writeFileSync(path.join(customShared, 'fixtures', 'appConfig.json'), JSON.stringify({ env: 'staging' }));
|
|
362
|
+
const portalFeature = path.join(tmpDir, 'apps', 'portal', 'e2e');
|
|
363
|
+
fs.mkdirSync(path.join(portalFeature, 'specs', 'Auth'), { recursive: true });
|
|
364
|
+
fs.writeFileSync(path.join(portalFeature, 'specs', 'Auth', 'portal.web.test.ts'), 'it("test", () => {});');
|
|
365
|
+
const scopes = TypeGenerator.getEntityScopes(tmpDir);
|
|
366
|
+
const sharedScope = scopes.find((s) => s.isShared);
|
|
367
|
+
const featureScope = scopes.find((s) => !s.isShared && s.name === 'portal');
|
|
368
|
+
expect(sharedScope).toBeDefined();
|
|
369
|
+
expect(sharedScope?.dir).toBe(path.resolve(customShared));
|
|
370
|
+
expect(featureScope).toBeDefined();
|
|
371
|
+
TypeGenerator.generateAll(tmpDir);
|
|
372
|
+
// Shared declarations generated dynamically in .testspectra/types/shared/
|
|
373
|
+
const sharedCommonDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'shared', 'common.d.ts'), 'utf-8');
|
|
374
|
+
expect(sharedCommonDts).toContain('declare const CoreNav:');
|
|
375
|
+
expect(sharedCommonDts).toContain('coreAuth');
|
|
376
|
+
// Feature declarations generated dynamically in .testspectra/types/features/portal/
|
|
377
|
+
const featureCommonDts = fs.readFileSync(path.join(tmpDir, '.testspectra', 'types', 'features', 'portal', 'common.d.ts'), 'utf-8');
|
|
378
|
+
expect(featureCommonDts).toContain('declare const CoreNav:');
|
|
379
|
+
expect(featureCommonDts).toContain('coreAuth');
|
|
380
|
+
// Pure monorepo with zero root entities: root platform .d.ts files must NOT be generated
|
|
381
|
+
expect(fs.existsSync(path.join(tmpDir, '.testspectra', 'types', 'android.d.ts'))).toBe(false);
|
|
382
|
+
expect(fs.existsSync(path.join(tmpDir, '.testspectra', 'types', 'ios.d.ts'))).toBe(false);
|
|
383
|
+
expect(fs.existsSync(path.join(tmpDir, '.testspectra', 'types', 'web.d.ts'))).toBe(false);
|
|
384
|
+
expect(fs.existsSync(path.join(tmpDir, '.testspectra', 'types', 'common.d.ts'))).toBe(false);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type EntityScope } from './type-generator.js';
|
|
2
|
+
export interface PlatformTsConfigOptions {
|
|
3
|
+
cwd: string;
|
|
4
|
+
force?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class TsConfigGenerator {
|
|
7
|
+
static getRootTsConfig(): object;
|
|
8
|
+
static getMasterSolutionConfig(references?: {
|
|
9
|
+
path: string;
|
|
10
|
+
}[]): object;
|
|
11
|
+
static getStemExcludes(prefix: string, stems: string[]): string[];
|
|
12
|
+
static getWebConfig(): object;
|
|
13
|
+
static getMobileConfig(): object;
|
|
14
|
+
static getAndroidConfig(): object;
|
|
15
|
+
static getIosConfig(): object;
|
|
16
|
+
static getCommonConfig(): object;
|
|
17
|
+
static getScopedConfig(options: {
|
|
18
|
+
cwd: string;
|
|
19
|
+
subConfigDir: string;
|
|
20
|
+
scopeDir: string;
|
|
21
|
+
relTypesDir: string;
|
|
22
|
+
platform: 'web' | 'mobile' | 'android' | 'ios' | 'common';
|
|
23
|
+
}): object;
|
|
24
|
+
static getEntityScopes(cwd: string): EntityScope[];
|
|
25
|
+
static writeConfigs(cwd: string, providedScopes?: EntityScope[]): Record<string, string>;
|
|
26
|
+
static scaffoldConfigs(cwd: string, force?: boolean): Record<string, string>;
|
|
27
|
+
}
|