@testspectra/cli 1.0.26 → 1.0.28

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.
@@ -362,8 +362,8 @@ export async function addCommand(moduleNameArg, options = {}) {
362
362
  // Create starter page object
363
363
  const poContent = `class ${targetModule}Page {\n get mainTitle() {\n return $("h1");\n }\n\n async open() {\n await Spectra.navigate("/${targetModule.toLowerCase()}");\n }\n}\n\nexport default new ${targetModule}Page();\n`;
364
364
  fs.writeFileSync(path.join(poDir, "common.ts"), poContent, "utf-8");
365
- // Create starter test spec
366
- const specContent = `describe("${targetModule} Test Suite", () => {\n it("should verify ${targetModule} page components", async () => {\n await ${targetModule}Page.open();\n await ${targetModule}Page.mainTitle.shouldBeVisible();\n });\n});\n`;
365
+ // Create starter test spec (Zero-import, flat it() block)
366
+ const specContent = `it("should verify ${targetModule} page components", async () => {\n await ${targetModule}Page.open();\n await ${targetModule}Page.mainTitle.shouldBeVisible();\n});\n`;
367
367
  fs.writeFileSync(path.join(specDir, "web.test.ts"), specContent, "utf-8");
368
368
  TypeGenerator.writeDeclarationFiles(cwd);
369
369
  p.log.success(chalk.green(`Created Page Object: ./page-objects/${targetModule}Page/common.ts`));
@@ -434,7 +434,7 @@ This workspace uses TestSpectra's **"Centralized Configuration, Distributed Impl
434
434
  - \`./pnpm-workspace.yaml\`: Monorepo package glob definitions.
435
435
  - \`./tsconfig.json\`: Solution-style TypeScript orchestrator linking all distributed E2E projects and shared libraries.
436
436
 
437
- ### Centralized Shared Library (\`./${sharedTestingRelPath}\`)
437
+ ### Centralized Shared Testing Library (\`./${sharedTestingRelPath}\`)
438
438
  Provides cross-feature reusable test entities with **100% zero-import global resolution**:
439
439
  - \`page-objects/\`: Shared Page Object models (e.g. NavigationBar, AppHeader).
440
440
  - \`steps/\`: Cross-feature business step flows (e.g. \`Step.loginAsAdmin()\`).
@@ -445,45 +445,107 @@ Provides cross-feature reusable test entities with **100% zero-import global res
445
445
  ${featureE2eDirs.map((d) => {
446
446
  const rel = path.relative(cwd, d);
447
447
  const name = path.basename(path.dirname(d));
448
- return `- \`./${rel}\` (**${name}**):
449
- - \`specs/\`: Feature test cases (\`specs/<SuiteName>/<CaseId>/\` for web, android, ios).
450
- - \`page-objects/\`: Feature-specific Page Objects (e.g. LoginPage, ProductPage).
448
+ const e2eName = `${name}-${e2eFolderName}`;
449
+ return `- \`./${rel}\` (**${name}**, Nx Project: \`${e2eName}\`):
450
+ - \`specs/\`: Feature test cases (\`specs/<SuiteName>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
451
+ - \`page-objects/\`: Feature-specific Page Objects (e.g. \`LoginPage\`, \`ProductPage\`).
451
452
  - \`project.json\`: Nx targets (\`e2e\`, \`type-check\`) supporting configurations (\`--configuration=android\`, \`--configuration=ios\`, \`--configuration=headless\`).
452
453
  - \`tsconfig.json\`: Solution TypeScript config reference.`;
453
454
  }).join("\n")}
454
455
 
455
456
  ---
456
457
 
457
- ## 2. Zero-Import Consumption Flow
458
+ ## 2. Zero-Import Consumption Flow & Mechanics
458
459
 
459
- \`\`\`
460
- ┌──────────────────────────────┐ ┌──────────────────────────────┐
461
- │ ${sharedPoLine} │ │ packages/*/e2e/specs/ │
462
- │ ${sharedStepsLine} │ ───────► │ (Zero-Import Test Cases) │
463
- │ ${sharedActLine} │ │ - NavigationBar.goToHome() │
464
- │ ${sharedFixLine} │ │ - Step.loginAsAdmin() │
465
- └──────────────────────────────┘ │ - Spectra.dismissBanner() │
466
- └──────────────────────────────┘
460
+ TestSpectra completely eliminates boilerplate \`import\` statements across all test specs, steps, and page objects.
461
+
462
+ ### How It Works:
463
+ 1. **Centralized Ambient Aggregation**:
464
+ TestSpectra Language Service Plugin & CLI automatically scan:
465
+ - **Local Feature Entities**: \`<feature>/${e2eFolderName}/page-objects/\`, \`<feature>/${e2eFolderName}/steps/\`, \`<feature>/${e2eFolderName}/actions/\`
466
+ - **Shared Library Entities**: \`./${sharedTestingRelPath}/page-objects/\`, \`./${sharedTestingRelPath}/steps/\`, \`./${sharedTestingRelPath}/actions/\`, \`./${sharedTestingRelPath}/fixtures/\`
467
+ 2. **Ambient Typing Generation**:
468
+ These are compiled into \`.testspectra/types/web.d.ts\`, \`android.d.ts\`, \`ios.d.ts\`, \`fixtures.d.ts\`.
469
+ 3. **Instant IDE Autocomplete & Zero Clutter**:
470
+ Specs consume both local feature objects and shared library utilities globally.
471
+
472
+ ### Code Example:
473
+ \`\`\`typescript
474
+ // packages/features/auth/e2e/specs/Auth/TC-AUTH-01/web.test.ts
475
+ // 🌟 NOTICE: 100% Zero-Import & Flat Execution! (No import statement, no describe wrapper)
476
+
477
+ it("should navigate via shared header and login with local POM", async () => {
478
+ // 1. Consumed from Shared Testing Library (${sharedTestingRelPath}/page-objects/NavigationBar)
479
+ await NavigationBar.goToLogin();
480
+
481
+ // 2. Consumed from Shared Testing Library (${sharedTestingRelPath}/steps/loginAsAdmin)
482
+ await Step.loginAsAdmin();
483
+
484
+ // 3. Consumed from Local Feature POM (page-objects/LoginPage)
485
+ await LoginPage.flashAlert.shouldBeVisible();
486
+ await LoginPage.flashAlert.shouldContainText("Welcome");
487
+
488
+ // 4. Consumed from Shared Testing Library Custom Action (${sharedTestingRelPath}/actions/dismissBanner)
489
+ await Spectra.dismissBanner();
490
+ });
467
491
  \`\`\`
468
492
 
469
493
  ---
470
494
 
471
- ## 3. Running Tests via Nx
495
+ ## 3. How to Run Tests
496
+
497
+ You can execute tests either from the **Monorepo Root via Nx** or directly inside each **Feature Directory via CLI**:
498
+
499
+ ### Option A: From Root Monorepo via Nx (Recommended for CI & Team Workflows)
472
500
 
473
501
  \`\`\`bash
474
- # Run all feature E2E suites in parallel
502
+ # 1. Run E2E for a SPECIFIC feature module (e.g. auth)
503
+ pnpm nx run auth-${e2eFolderName}:e2e
504
+
505
+ # 2. Run E2E for a specific feature on ANDROID or IOS
506
+ pnpm nx run auth-${e2eFolderName}:e2e --configuration=android
507
+ pnpm nx run auth-${e2eFolderName}:e2e --configuration=ios
508
+
509
+ # 3. Run E2E for a specific feature in HEADLESS browser mode
510
+ pnpm nx run auth-${e2eFolderName}:e2e --configuration=headless
511
+
512
+ # 4. Run ALL feature E2E suites across the entire monorepo in parallel
475
513
  pnpm nx run-many -t e2e
476
514
 
477
- # Run only E2E tests for features changed in PR
515
+ # 5. Run only E2E tests for features modified in current Git branch / PR
478
516
  pnpm nx affected -t e2e
517
+ \`\`\`
479
518
 
480
- # Run E2E for a specific feature on Android
481
- pnpm nx run auth-${e2eFolderName}:e2e --configuration=android
519
+ ### Option B: From Inside the Feature Directory (Direct CLI)
520
+
521
+ \`\`\`bash
522
+ # Navigate to the feature e2e folder
523
+ cd ${featureE2eDirs.length > 0 ? path.relative(cwd, featureE2eDirs[0]).replace(/\\/g, "/") : `modules/auth/${e2eFolderName}`}
524
+
525
+ # Run all specs in this feature
526
+ pnpm spectra run
527
+
528
+ # Run a specific test case file
529
+ pnpm spectra run specs/Auth/TC-AUTH-01/web.test.ts
530
+
531
+ # Target Android device or emulator
532
+ pnpm spectra run --target android
482
533
 
483
- # Run type check across all E2E projects
534
+ # Run in headed / interactive browser mode
535
+ pnpm spectra run --no-headless
536
+ \`\`\`
537
+
538
+ ---
539
+
540
+ ## 4. Type Checking & Validation
541
+
542
+ \`\`\`bash
543
+ # Type check all E2E projects via Nx
484
544
  pnpm nx run-many -t type-check
485
- # Or standard TypeScript compilation
545
+
546
+ # Or standard TypeScript project references build from root
486
547
  pnpm type-check
548
+ # or: npx tsc -b
487
549
  \`\`\`
488
550
  `;
489
551
  fs.writeFileSync(path.join(cwd, "ARCHITECTURE.md"), archDocContent, "utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testspectra/cli",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "TestSpectra Zero-Config Cross-Platform Test Runner CLI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",