@testspectra/cli 1.1.8-rc.18 → 1.1.8-rc.20

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.
@@ -78,26 +78,6 @@ function ensurePnpmWorkspaceIncludes(pnpmWorkspacePath, targetPath) {
78
78
  }
79
79
  }
80
80
  }
81
- function renderArchitectureDoc(templatePath, replacements) {
82
- let content = fs.readFileSync(templatePath, 'utf-8');
83
- for (const [token, value] of Object.entries(replacements)) {
84
- content = content.replaceAll(token, value);
85
- }
86
- return content;
87
- }
88
- function buildFeatureModulesSection(cwd, featureE2eDirs, e2eFolderName) {
89
- return featureE2eDirs
90
- .map((d) => {
91
- const rel = path.relative(cwd, d).replace(/\\/g, '/');
92
- const name = path.basename(path.dirname(d));
93
- const e2eName = `${name}-${e2eFolderName}`;
94
- return `- \`./${rel}\` (**${name}**, Nx Project: \`${e2eName}\`):
95
- - \`specs/\`: Feature test cases (\`specs/<SuiteName>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
96
- - \`page-objects/\`: Feature-specific Page Objects (e.g. \`LoginPage\`, \`ProductPage\`).
97
- - \`project.json\`: Nx targets (\`e2e\`, \`type-check\`) supporting configurations (\`--configuration=android\`, \`--configuration=ios\`, \`--configuration=headless\`).`;
98
- })
99
- .join('\n');
100
- }
101
81
  function ensureVsCodeExtensions(cwd) {
102
82
  const vscodeDir = path.join(cwd, '.vscode');
103
83
  const extFile = path.join(vscodeDir, 'extensions.json');
@@ -267,7 +247,6 @@ export async function initCommand(options = {}) {
267
247
  p.cancel(chalk.red(`Template directory not found: ${templateDir}`));
268
248
  return;
269
249
  }
270
- const docsTemplateDir = path.join(path.dirname(templateDir), 'docs');
271
250
  // 2. Resolve CLI dependency version
272
251
  let cliVersion = '^1.0.65';
273
252
  try {
@@ -579,15 +558,136 @@ export async function initCommand(options = {}) {
579
558
  // 7. Generate Ambient Types in ROOT only
580
559
  TypeGenerator.writeDeclarationFiles(cwd);
581
560
  ensureVsCodeExtensions(cwd);
582
- const archDocContent = renderArchitectureDoc(path.join(docsTemplateDir, 'ARCHITECTURE.nx.md'), {
583
- __SHARED_TESTING_REL_PATH__: sharedTestingRelPath,
584
- __FEATURE_COUNT__: String(featureE2eDirs.length),
585
- __FEATURE_MODULES_SECTION__: buildFeatureModulesSection(cwd, featureE2eDirs, e2eFolderName),
586
- __E2E_FOLDER_NAME__: e2eFolderName,
587
- __SAMPLE_FEATURE_E2E_PATH__: featureE2eDirs.length > 0
588
- ? path.relative(cwd, featureE2eDirs[0]).replace(/\\/g, '/')
589
- : `modules/auth/${e2eFolderName}`,
590
- });
561
+ const archDocContent = `# TestSpectra Enterprise Monorepo Architecture
562
+
563
+ This workspace uses TestSpectra's **"Centralized Configuration, Distributed Implementation"** model for automated cross-platform testing.
564
+
565
+ ---
566
+
567
+ ## 1. Directory & File Overview
568
+
569
+ ### Centralized Root Elements
570
+ - \`./spectra.config.ts\`: Single source of truth for runtime configurations (Base URL, Appium devices, browser targets, timeouts).
571
+ - \`./.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/\`.
572
+ - \`./nx.json\`: Nx target defaults with execution caching and inputs.
573
+ - \`./pnpm-workspace.yaml\`: Monorepo package glob definitions.
574
+ - \`./tsconfig.json\`: Solution-style TypeScript orchestrator referencing \`./.testspectra/tsconfig.json\`.
575
+
576
+ ### Centralized Shared Testing Library (\`./${sharedTestingRelPath}\`)
577
+ Provides cross-feature reusable test entities with **100% zero-import global resolution**:
578
+ - \`page-objects/\`: Shared Page Object models (e.g. NavigationBar, AppHeader).
579
+ - \`steps/\`: Cross-feature business step flows (e.g. \`Step.loginAsAdmin()\`).
580
+ - \`actions/\`: Custom atomic actions (e.g. \`Spectra.dismissBanner()\`).
581
+ - \`fixtures/\`: Common test data and environment configurations (e.g. \`Fixture.appConfig\`).
582
+
583
+ ### Distributed Feature E2E Modules (${featureE2eDirs.length} Features)
584
+ ${featureE2eDirs
585
+ .map((d) => {
586
+ const rel = path.relative(cwd, d);
587
+ const name = path.basename(path.dirname(d));
588
+ const e2eName = `${name}-${e2eFolderName}`;
589
+ return `- \`./${rel}\` (**${name}**, Nx Project: \`${e2eName}\`):
590
+ - \`specs/\`: Feature test cases (\`specs/<SuiteName>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
591
+ - \`page-objects/\`: Feature-specific Page Objects (e.g. \`LoginPage\`, \`ProductPage\`).
592
+ - \`project.json\`: Nx targets (\`e2e\`, \`type-check\`) supporting configurations (\`--configuration=android\`, \`--configuration=ios\`, \`--configuration=headless\`).`;
593
+ })
594
+ .join('\n')}
595
+
596
+ ---
597
+
598
+ ## 2. Zero-Import Consumption Flow & Mechanics
599
+
600
+ TestSpectra completely eliminates boilerplate \`import\` statements across all test specs, steps, and page objects.
601
+
602
+ ### How It Works:
603
+ 1. **Centralized Ambient Aggregation**:
604
+ TestSpectra Language Service Plugin & CLI automatically scan:
605
+ - **Local Feature Entities**: \`<feature>/${e2eFolderName}/page-objects/\`, \`<feature>/${e2eFolderName}/steps/\`, \`<feature>/${e2eFolderName}/actions/\`
606
+ - **Shared Library Entities**: \`./${sharedTestingRelPath}/page-objects/\`, \`./${sharedTestingRelPath}/steps/\`, \`./${sharedTestingRelPath}/actions/\`, \`./${sharedTestingRelPath}/fixtures/\`
607
+ 2. **Ambient Typing Generation**:
608
+ These are compiled into \`.testspectra/types/web.d.ts\`, \`android.d.ts\`, \`ios.d.ts\`, \`fixtures.d.ts\`.
609
+ 3. **Instant IDE Autocomplete & Zero Clutter**:
610
+ Specs consume both local feature objects and shared library utilities globally.
611
+
612
+ ### Code Example:
613
+ \`\`\`typescript
614
+ // packages/features/auth/e2e/specs/Auth/TC-AUTH-01/web.test.ts
615
+ // 🌟 NOTICE: 100% Zero-Import & Flat Execution! (No import statement, no describe wrapper)
616
+
617
+ it("should navigate via shared header and login with local POM", async () => {
618
+ // 1. Consumed from Shared Testing Library (${sharedTestingRelPath}/page-objects/NavigationBar)
619
+ await NavigationBar.goToLogin();
620
+
621
+ // 2. Consumed from Shared Testing Library (${sharedTestingRelPath}/steps/loginAsAdmin)
622
+ await Step.loginAsAdmin();
623
+
624
+ // 3. Consumed from Local Feature POM (page-objects/LoginPage)
625
+ await LoginPage.flashAlert.shouldBeVisible();
626
+ await LoginPage.flashAlert.shouldContainText("Welcome");
627
+
628
+ // 4. Consumed from Shared Testing Library Custom Action (${sharedTestingRelPath}/actions/dismissBanner)
629
+ await Spectra.dismissBanner();
630
+ });
631
+ \`\`\`
632
+
633
+ ---
634
+
635
+ ## 3. How to Run Tests
636
+
637
+ You can execute tests either from the **Monorepo Root via Nx** or directly inside each **Feature Directory via CLI**:
638
+
639
+ ### Option A: From Root Monorepo via Nx (Recommended for CI & Team Workflows)
640
+
641
+ \`\`\`bash
642
+ # 1. Run E2E for a SPECIFIC feature module (e.g. auth)
643
+ pnpm nx run auth-${e2eFolderName}:e2e
644
+
645
+ # 2. Run E2E for a specific feature on ANDROID or IOS
646
+ pnpm nx run auth-${e2eFolderName}:e2e --configuration=android
647
+ pnpm nx run auth-${e2eFolderName}:e2e --configuration=ios
648
+
649
+ # 3. Run E2E for a specific feature in HEADLESS browser mode
650
+ pnpm nx run auth-${e2eFolderName}:e2e --configuration=headless
651
+
652
+ # 4. Run ALL feature E2E suites across the entire monorepo in parallel
653
+ pnpm nx run-many -t e2e
654
+
655
+ # 5. Run only E2E tests for features modified in current Git branch / PR
656
+ pnpm nx affected -t e2e
657
+ \`\`\`
658
+
659
+ ### Option B: From Inside the Feature Directory (Direct CLI)
660
+
661
+ \`\`\`bash
662
+ # Navigate to the feature e2e folder
663
+ cd ${featureE2eDirs.length > 0 ? path.relative(cwd, featureE2eDirs[0]).replace(/\\/g, '/') : `modules/auth/${e2eFolderName}`}
664
+
665
+ # Run all specs in this feature
666
+ pnpm spectra run
667
+
668
+ # Run a specific test case file
669
+ pnpm spectra run specs/Auth/TC-AUTH-01/web.test.ts
670
+
671
+ # Target Android device or emulator
672
+ pnpm spectra run --target android
673
+
674
+ # Run in headed / interactive browser mode
675
+ pnpm spectra run --no-headless
676
+ \`\`\`
677
+
678
+ ---
679
+
680
+ ## 4. Type Checking & Validation
681
+
682
+ \`\`\`bash
683
+ # Type check all E2E projects via Nx
684
+ pnpm nx run-many -t type-check
685
+
686
+ # Or standard TypeScript project references build from root
687
+ pnpm type-check
688
+ # or: npx tsc -b
689
+ \`\`\`
690
+ `;
591
691
  fs.writeFileSync(path.join(cwd, 'ARCHITECTURE.md'), archDocContent, 'utf-8');
592
692
  // 8. Ensure root .gitignore ignores .testspectra/ and *.tsbuildinfo
593
693
  const rootGitignorePath = path.join(cwd, '.gitignore');
@@ -642,7 +742,34 @@ export async function initCommand(options = {}) {
642
742
  TypeGenerator.writeDeclarationFiles(cwd);
643
743
  ensureVsCodeExtensions(cwd);
644
744
  // Standalone Architecture Documentation
645
- fs.copyFileSync(path.join(docsTemplateDir, 'ARCHITECTURE.default.md'), path.join(cwd, 'ARCHITECTURE.md'));
745
+ const standaloneArchDoc = `# TestSpectra Project Architecture
746
+
747
+ This project is built with the TestSpectra testing framework.
748
+
749
+ ## Structure & File Map
750
+ - \`./spectra.config.ts\`: Typed runner configuration.
751
+ - \`./specs/\`: Layered test cases (\`specs/<Suite>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
752
+ - \`./page-objects/\`: Page Object models per platform.
753
+ - \`./steps/\`: Business flows accessible globally via \`Step.*\`.
754
+ - \`./actions/\`: Atomic actions accessible globally via \`Spectra.*\`.
755
+ - \`./fixtures/\`: JSON fixtures accessible globally via \`Fixture.*\`.
756
+ - \`./global-hooks/\`: Global suite lifecycle hooks.
757
+ - \`./.testspectra/\`: Auto-generated ambient typings and local runtime cache.
758
+
759
+ ## Execution
760
+ \`\`\`bash
761
+ # Run web test suite
762
+ pnpm test
763
+
764
+ # Run Android / iOS
765
+ pnpm spectra run --target android
766
+ pnpm spectra run --target ios
767
+
768
+ # Type check
769
+ pnpm type-check
770
+ \`\`\`
771
+ `;
772
+ fs.writeFileSync(path.join(cwd, 'ARCHITECTURE.md'), standaloneArchDoc, 'utf-8');
646
773
  // Safely update root README.md (do not overwrite existing content)
647
774
  const standaloneReadmePath = path.join(cwd, 'README.md');
648
775
  const standaloneArchSection = `\n## E2E Testing Architecture (TestSpectra)\n\nDetailed test architecture and folder map are documented in: \nšŸ‘‰ **[ARCHITECTURE.md](./ARCHITECTURE.md)**\n\n- **Run tests**: \`pnpm test\`\n- **Type-check**: \`pnpm type-check\`\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testspectra/cli",
3
- "version": "1.1.8-rc.18",
3
+ "version": "1.1.8-rc.20",
4
4
  "description": "TestSpectra Zero-Config Cross-Platform Test Runner CLI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,9 +26,9 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@clack/prompts": "^1.7.0",
29
- "@testspectra/matchers": "^1.1.8-rc.18",
30
- "@testspectra/react": "^1.1.8-rc.18",
31
- "@testspectra/skills": "^1.1.8-rc.18",
29
+ "@testspectra/matchers": "^1.1.8-rc.20",
30
+ "@testspectra/react": "^1.1.8-rc.20",
31
+ "@testspectra/skills": "^1.1.8-rc.20",
32
32
  "chalk": "^5.3.0",
33
33
  "commander": "^12.1.0",
34
34
  "dotenv": "^16.4.5",
@@ -38,10 +38,10 @@
38
38
  "zod": "^3.23.8"
39
39
  },
40
40
  "optionalDependencies": {
41
- "@testspectra/cli-darwin-arm64": "1.1.8-rc.18",
42
- "@testspectra/cli-linux-x64": "1.1.8-rc.18",
43
- "@testspectra/cli-win32-arm64": "1.1.8-rc.18",
44
- "@testspectra/cli-win32-x64": "1.1.8-rc.18"
41
+ "@testspectra/cli-darwin-arm64": "1.1.8-rc.20",
42
+ "@testspectra/cli-linux-x64": "1.1.8-rc.20",
43
+ "@testspectra/cli-win32-arm64": "1.1.8-rc.20",
44
+ "@testspectra/cli-win32-x64": "1.1.8-rc.20"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "^20.14.0",
@@ -17,8 +17,8 @@
17
17
  "postinstall": "spectra sync-types"
18
18
  },
19
19
  "devDependencies": {
20
- "@testspectra/cli": "^1.1.8-rc.18",
21
- "@testspectra/matchers": "^1.1.8-rc.18",
20
+ "@testspectra/cli": "^1.1.8-rc.20",
21
+ "@testspectra/matchers": "^1.1.8-rc.20",
22
22
  "@types/node": "^20.14.0",
23
23
  "@wdio/cli": "^9.2.8",
24
24
  "@wdio/local-runner": "^9.2.8",