@testspectra/cli 1.1.8-rc.8 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +11 -8
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/commands/__tests__/doctor-filter.test.d.ts +1 -0
  4. package/dist/commands/__tests__/doctor-filter.test.js +37 -0
  5. package/dist/commands/__tests__/test-error-streaming.test.d.ts +1 -0
  6. package/dist/commands/__tests__/test-error-streaming.test.js +85 -0
  7. package/dist/commands/__tests__/test-scaffolding.test.d.ts +1 -0
  8. package/dist/commands/__tests__/test-scaffolding.test.js +32 -0
  9. package/dist/commands/__tests__/upgrade.test.d.ts +1 -0
  10. package/dist/commands/__tests__/upgrade.test.js +95 -0
  11. package/dist/commands/add.js +5 -4
  12. package/dist/commands/devices.js +1 -0
  13. package/dist/commands/docs.d.ts +4 -0
  14. package/dist/commands/docs.js +17 -0
  15. package/dist/commands/doctor.d.ts +9 -1
  16. package/dist/commands/doctor.js +17 -3
  17. package/dist/commands/init.js +7 -160
  18. package/dist/commands/install.js +5 -0
  19. package/dist/commands/license.js +1 -0
  20. package/dist/commands/run.d.ts +2 -0
  21. package/dist/commands/run.js +22 -0
  22. package/dist/commands/test.d.ts +13 -0
  23. package/dist/commands/test.js +115 -21
  24. package/dist/commands/upgrade.d.ts +12 -0
  25. package/dist/commands/upgrade.js +197 -0
  26. package/dist/config/schema.d.ts +53 -0
  27. package/dist/config/schema.js +2 -0
  28. package/dist/generator/__tests__/tsconfig-isolation.test.js +2 -1
  29. package/dist/generator/__tests__/type-generator.test.js +38 -0
  30. package/dist/generator/architecture-doc-generator.d.ts +14 -0
  31. package/dist/generator/architecture-doc-generator.js +80 -0
  32. package/dist/generator/index.d.ts +1 -0
  33. package/dist/generator/index.js +1 -0
  34. package/dist/generator/tsconfig-generator.js +1 -1
  35. package/dist/generator/type-generator.d.ts +5 -2
  36. package/dist/generator/type-generator.js +14 -17
  37. package/dist/index.js +59 -16
  38. package/dist/linter/__tests__/shared-lib-boundary.test.js +15 -15
  39. package/dist/linter/discovery.d.ts +3 -3
  40. package/dist/linter/discovery.js +7 -7
  41. package/dist/linter/schemas/spec.schema.d.ts +6 -6
  42. package/dist/runner/bridge.d.ts +1 -1
  43. package/dist/runner/bridge.js +67 -16
  44. package/dist/runner/reporter.d.ts +1 -0
  45. package/dist/runner/reporter.js +12 -6
  46. package/dist/utils/__tests__/dev-server-manager.test.d.ts +1 -0
  47. package/dist/utils/__tests__/dev-server-manager.test.js +72 -0
  48. package/dist/utils/background-update-check.d.ts +1 -0
  49. package/dist/utils/background-update-check.js +43 -0
  50. package/dist/utils/dependency-updates.d.ts +15 -0
  51. package/dist/utils/dependency-updates.js +107 -0
  52. package/dist/utils/dev-server-manager.d.ts +40 -0
  53. package/dist/utils/dev-server-manager.js +257 -0
  54. package/dist/utils/update-notifier.d.ts +2 -0
  55. package/dist/utils/update-notifier.js +67 -0
  56. package/package.json +10 -9
  57. package/templates/default/package.json +2 -2
  58. package/templates/docs/ARCHITECTURE.default.md +26 -0
  59. package/templates/docs/ARCHITECTURE.nx.md +147 -0
  60. package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db +0 -0
  61. package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db-shm +0 -0
  62. package/templates/nx/.nx/workspace-data/70094CFD-E89B-57A1-9619-2FC5F4963C54.db-wal +0 -0
  63. package/templates/nx/.nx/workspace-data/d/daemon.log +947 -0
  64. package/templates/nx/.nx/workspace-data/d/server-process.json +1 -1
  65. package/templates/nx/.nx/workspace-data/file-map.json +172 -186
  66. package/templates/nx/.nx/workspace-data/lockfile.hash +1 -1
  67. package/templates/nx/.nx/workspace-data/nx_files.nxt +0 -0
  68. package/templates/nx/.nx/workspace-data/parsed-lock-file.json +81 -130
  69. package/templates/nx/.nx/workspace-data/project-graph.json +90 -144
  70. package/templates/nx/.nx/workspace-data/source-maps.json +336 -0
  71. package/templates/nx/package.json +3 -3
  72. package/templates/nx/packages/matchers/e2e/project.json +2 -2
  73. package/templates/nx/packages/playground/e2e/project.json +2 -2
  74. package/templates/nx/pnpm-lock.yaml +191 -214
  75. package/templates/nx/shared/testing/project.json +1 -2
  76. package/templates/nx/spectra.config.ts +13 -0
  77. package/templates/react-component/package.json +3 -3
  78. package/templates/react-component/page-objects/BadgeComponent/web.ts +4 -4
  79. package/templates/react-component/page-objects/ButtonComponent/web.ts +3 -3
  80. package/templates/react-component/page-objects/InputComponent/web.ts +1 -1
  81. package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/web.test.tsx +0 -3
  82. package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/web.test.tsx +0 -9
  83. package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/web.test.tsx +1 -1
  84. package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/web.test.tsx +4 -8
  85. package/templates/react-component/spectra.config.ts +0 -10
  86. package/templates/react-component/src/components/Badge/Badge.tsx +3 -3
  87. package/templates/react-component/src/components/Button/Button.tsx +5 -3
  88. package/templates/react-component/src/components/Input/Input.tsx +2 -3
@@ -0,0 +1,37 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ const { execFileSyncMock } = vi.hoisted(() => ({ execFileSyncMock: vi.fn() }));
3
+ vi.mock('child_process', () => ({
4
+ execFileSync: execFileSyncMock,
5
+ spawn: vi.fn(),
6
+ }));
7
+ vi.mock('../../runner/bridge.js', () => ({
8
+ RustCoreBridge: { resolveBinaryPath: () => '/fake/testspectra-runner' },
9
+ }));
10
+ import { runSystemChecks } from '../doctor.js';
11
+ const EMPTY = JSON.stringify({ all_ready: true, missing_count: 0, dependencies: [] });
12
+ describe('runSystemChecks filter forwarding', () => {
13
+ it('forwards a category scope to the runner', async () => {
14
+ execFileSyncMock.mockReturnValueOnce(EMPTY);
15
+ await runSystemChecks('/tmp/ws', { scope: 'web' });
16
+ const [, args] = execFileSyncMock.mock.calls.at(-1);
17
+ expect(args).toEqual(['doctor', '--json', '--scope', 'web']);
18
+ });
19
+ it('forwards a fine-grained --only filter (single dependency)', async () => {
20
+ execFileSyncMock.mockReturnValueOnce(EMPTY);
21
+ await runSystemChecks('/tmp/ws', { only: 'chrome' });
22
+ const [, args] = execFileSyncMock.mock.calls.at(-1);
23
+ expect(args).toEqual(['doctor', '--json', '--only', 'chrome']);
24
+ });
25
+ it('forwards both scope and only when provided', async () => {
26
+ execFileSyncMock.mockReturnValueOnce(EMPTY);
27
+ await runSystemChecks('/tmp/ws', { scope: 'web', only: 'chrome,adb' });
28
+ const [, args] = execFileSyncMock.mock.calls.at(-1);
29
+ expect(args).toEqual(['doctor', '--json', '--scope', 'web', '--only', 'chrome,adb']);
30
+ });
31
+ it('omits filters entirely when none are requested (full doctor)', async () => {
32
+ execFileSyncMock.mockReturnValueOnce(EMPTY);
33
+ await runSystemChecks('/tmp/ws');
34
+ const [, args] = execFileSyncMock.mock.calls.at(-1);
35
+ expect(args).toEqual(['doctor', '--json']);
36
+ });
37
+ });
@@ -0,0 +1,85 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { isVitestNoise, sanitizeErrorMessage } from '@testspectra/react';
3
+ import { Reporter } from '../../runner/reporter.js';
4
+ describe('spectra test error streaming and formatting', () => {
5
+ it('sanitizes Vitest/Vite error messages without leaking behind-the-scenes tooling', () => {
6
+ const rawError = 'Failed to fetch dynamically imported module: http://localhost:63315/@fs/D:/wangs-ui-react/packages/testing-library/page-objects/AccordionComponent/web.ts?import';
7
+ const sanitized = sanitizeErrorMessage(rawError);
8
+ expect(sanitized).toBe('Failed to load module: D:/wangs-ui-react/packages/testing-library/page-objects/AccordionComponent/web.ts');
9
+ expect(sanitized).not.toContain('localhost');
10
+ expect(sanitized).not.toContain('@fs');
11
+ expect(sanitized).not.toContain('?import');
12
+ });
13
+ it('filters Vitest CLI runner noise while allowing actual errors through', () => {
14
+ expect(isVitestNoise('RUN v2.1.8 /Volumes/Home/TestSpectra')).toBe(true);
15
+ expect(isVitestNoise('Test Files 1 failed (1)')).toBe(true);
16
+ expect(isVitestNoise('āŽÆāŽÆāŽÆāŽÆāŽÆāŽÆāŽÆ Failed Suites 1 āŽÆāŽÆāŽÆāŽÆāŽÆāŽÆāŽÆ')).toBe(true);
17
+ expect(isVitestNoise('Re-optimizing dependencies because vite config has changed')).toBe(true);
18
+ expect(isVitestNoise('Error: Cannot find module "./Button"')).toBe(false);
19
+ expect(isVitestNoise('SyntaxError: Unexpected token (10:15)')).toBe(false);
20
+ });
21
+ it('formats multi-line errors with clean indentation in Reporter', () => {
22
+ const reporter = new Reporter();
23
+ reporter.addLog({
24
+ timestamp: '12:00:00',
25
+ level: 'INFO',
26
+ message: '[TESTSPECTRA_TEST_START] {"title":"specs/Accordion/TC-0009/web.test.tsx"}',
27
+ });
28
+ reporter.addLog({
29
+ timestamp: '12:00:00',
30
+ level: 'INFO',
31
+ message: '[TESTSPECTRA_TEST_ERROR] Failed to load module: D:/wangs-ui-react/page-objects/Accordion/web.ts',
32
+ });
33
+ reporter.addLog({
34
+ timestamp: '12:00:00',
35
+ level: 'INFO',
36
+ message: '[TESTSPECTRA_TEST_FAIL] specs/Accordion/TC-0009/web.test.tsx (0ms)',
37
+ });
38
+ const result = reporter.generateResult('failed', '0.1s');
39
+ expect(result.failedCount).toBe(1);
40
+ expect(result.passedCount).toBe(0);
41
+ expect(result.status).toBe('failed');
42
+ });
43
+ it('prints error message below test title and steps on failure', () => {
44
+ const reporter = new Reporter();
45
+ const consoleLogs = [];
46
+ const spy = vi.spyOn(console, 'log').mockImplementation((msg) => {
47
+ if (typeof msg === 'string')
48
+ consoleLogs.push(msg);
49
+ });
50
+ reporter.addLog({
51
+ timestamp: '12:00:00',
52
+ level: 'INFO',
53
+ message: '[TESTSPECTRA_TEST_START] {"title":"ApiInterception / TC-0009-post-mocking"}',
54
+ });
55
+ reporter.addLog({
56
+ timestamp: '12:00:00',
57
+ level: 'INFO',
58
+ message: '[TESTSPECTRA_STEP_PASS] {"type":"action","key":"navigate","args":["/#api-post"],"test":"ApiInterception / TC-0009-post-mocking"} (8ms)',
59
+ });
60
+ reporter.addLog({
61
+ timestamp: '12:00:00',
62
+ level: 'INFO',
63
+ message: '[TESTSPECTRA_STEP_FAIL] {"type":"assertion","target":"#post-status-badge","args":["201 Created"],"test":"ApiInterception / TC-0009-post-mocking"} (2005ms)',
64
+ });
65
+ reporter.addLog({
66
+ timestamp: '12:00:00',
67
+ level: 'INFO',
68
+ message: '[TESTSPECTRA_TEST_ERROR] Expected element "#post-status-badge" to have text "201 Created", but got ""',
69
+ });
70
+ reporter.addLog({
71
+ timestamp: '12:00:00',
72
+ level: 'INFO',
73
+ message: '[TESTSPECTRA_TEST_FAIL] ApiInterception / TC-0009-post-mocking (2066ms)',
74
+ });
75
+ spy.mockRestore();
76
+ const titleIndex = consoleLogs.findIndex((log) => log.includes('ApiInterception / TC-0009-post-mocking'));
77
+ const stepPassIndex = consoleLogs.findIndex((log) => log.includes('Navigate to'));
78
+ const stepFailIndex = consoleLogs.findIndex((log) => log.includes('#post-status-badge'));
79
+ const errorIndex = consoleLogs.findIndex((log) => log.includes('↳ Error:'));
80
+ expect(titleIndex).toBeGreaterThanOrEqual(0);
81
+ expect(stepPassIndex).toBeGreaterThan(titleIndex);
82
+ expect(stepFailIndex).toBeGreaterThan(stepPassIndex);
83
+ expect(errorIndex).toBeGreaterThan(stepFailIndex);
84
+ });
85
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
5
+ import { ensureTestSpectraScaffolding } from '../test.js';
6
+ describe('spectra test pre-flight scaffolding (docs/v2/features/component-testing/react/README.md)', () => {
7
+ let tmpDir;
8
+ beforeEach(() => {
9
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'testspectra-test-scaffold-'));
10
+ });
11
+ afterEach(() => {
12
+ try {
13
+ fs.rmSync(tmpDir, { recursive: true, force: true });
14
+ }
15
+ catch { }
16
+ });
17
+ it('generates the .testspectra solution tsconfig when it is missing (clean clone / CI)', () => {
18
+ const masterConfig = path.join(tmpDir, '.testspectra', 'tsconfig.json');
19
+ expect(fs.existsSync(masterConfig)).toBe(false);
20
+ ensureTestSpectraScaffolding(tmpDir);
21
+ // The exact file `vite:esbuild` tries to read via the root tsconfig's `references` entry.
22
+ expect(fs.existsSync(masterConfig)).toBe(true);
23
+ expect(fs.existsSync(path.join(tmpDir, '.testspectra', 'tsconfig', 'web.json'))).toBe(true);
24
+ });
25
+ it('leaves an existing scaffolding untouched', () => {
26
+ const masterConfig = path.join(tmpDir, '.testspectra', 'tsconfig.json');
27
+ fs.mkdirSync(path.dirname(masterConfig), { recursive: true });
28
+ fs.writeFileSync(masterConfig, '{"custom":true}\n', 'utf-8');
29
+ ensureTestSpectraScaffolding(tmpDir);
30
+ expect(fs.readFileSync(masterConfig, 'utf-8')).toBe('{"custom":true}\n');
31
+ });
32
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import { execFileSync, execSync } from 'child_process';
5
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
6
+ import { upgradeCommand } from '../upgrade.js';
7
+ const DOCTOR_JSON = JSON.stringify({
8
+ all_ready: true,
9
+ missing_count: 0,
10
+ dependencies: [
11
+ {
12
+ name: 'Google Chrome',
13
+ category: 'web',
14
+ installed: true,
15
+ version: 'Google Chrome 123.0.0.0 (Chrome for Testing)',
16
+ required: true,
17
+ required_version: 'Stable / CfT',
18
+ depends_on: [],
19
+ },
20
+ {
21
+ name: 'Bun',
22
+ category: 'core',
23
+ installed: true,
24
+ version: 'v1.0.0',
25
+ required: true,
26
+ required_version: '>=1.0.0',
27
+ depends_on: [],
28
+ },
29
+ ],
30
+ });
31
+ vi.mock('child_process', () => ({
32
+ execFileSync: vi.fn((_cmd, args) => Array.isArray(args) && args[0] === 'doctor' ? DOCTOR_JSON : '"9.9.9"'),
33
+ execSync: vi.fn(),
34
+ }));
35
+ describe('upgradeCommand self-upgrade mechanism (docs/v2/features/upgrade-mechanism-and-notifications.md)', () => {
36
+ let tmpDir;
37
+ const originalCwd = process.cwd();
38
+ beforeEach(() => {
39
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'testspectra-upgrade-test-'));
40
+ process.chdir(tmpDir);
41
+ vi.clearAllMocks();
42
+ vi.stubGlobal('fetch', vi.fn(async (url) => {
43
+ const href = String(url);
44
+ if (href.includes('chrome-for-testing')) {
45
+ return { ok: true, json: async () => ({ channels: { Stable: { version: '999.0.0.0' } } }) };
46
+ }
47
+ if (href.includes('github')) {
48
+ return { ok: true, json: async () => ({ tag_name: 'bun-v2.0.0' }) };
49
+ }
50
+ return {
51
+ ok: true,
52
+ text: async () => '<remotePackage path="platform-tools"><revision><major>99</major><minor>0</minor><micro>0</micro></revision></remotePackage>',
53
+ };
54
+ }));
55
+ });
56
+ afterEach(() => {
57
+ vi.unstubAllGlobals();
58
+ process.chdir(originalCwd);
59
+ try {
60
+ fs.rmSync(tmpDir, { recursive: true, force: true });
61
+ }
62
+ catch { }
63
+ });
64
+ it('emits a pure JSON payload covering packages and drivers in --json mode', async () => {
65
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
66
+ await upgradeCommand([], { json: true });
67
+ expect(logSpy).toHaveBeenCalledTimes(1);
68
+ const payload = JSON.parse(logSpy.mock.calls[0][0]);
69
+ expect(payload.packages).toHaveLength(3);
70
+ expect(payload.packages.every((p) => p.latest === '9.9.9')).toBe(true);
71
+ expect(payload.drivers).toHaveLength(2);
72
+ expect(payload.drivers.find((d) => d.name === 'Google Chrome')?.latest).toBe('999.0.0.0');
73
+ expect(payload.updatesAvailable).toBeGreaterThan(0);
74
+ expect(execSync).not.toHaveBeenCalled();
75
+ logSpy.mockRestore();
76
+ });
77
+ it('restricts to a single package (no drivers) when package names are passed', async () => {
78
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
79
+ await upgradeCommand(['@testspectra/cli'], { json: true });
80
+ const payload = JSON.parse(logSpy.mock.calls[0][0]);
81
+ expect(payload.packages).toHaveLength(1);
82
+ expect(payload.packages[0].pkg).toBe('@testspectra/cli');
83
+ expect(payload.drivers).toHaveLength(0);
84
+ logSpy.mockRestore();
85
+ });
86
+ it('reports available updates in --check mode without running the package manager', async () => {
87
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
88
+ await upgradeCommand([], { check: true });
89
+ expect(execFileSync).toHaveBeenCalled();
90
+ expect(execSync).not.toHaveBeenCalled();
91
+ const output = logSpy.mock.calls.map((c) => String(c[0])).join('\n');
92
+ expect(output).toContain('package update(s) available');
93
+ logSpy.mockRestore();
94
+ });
95
+ });
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'url';
4
4
  import * as p from '@clack/prompts';
5
5
  import chalk from 'chalk';
6
6
  import { TypeGenerator } from '../types/generator.js';
7
+ import { ConfigLoader } from '../config/loader.js';
7
8
  function parsePnpmWorkspaceGlobs(content) {
8
9
  const lines = content.split('\n');
9
10
  const globs = [];
@@ -107,9 +108,8 @@ export async function addCommand(moduleNameArg, options = {}) {
107
108
  let rootDir = cwd;
108
109
  let cur = cwd;
109
110
  while (cur !== path.dirname(cur)) {
110
- if (fs.existsSync(path.join(cur, 'spectra.config.ts')) ||
111
- fs.existsSync(path.join(cur, 'pnpm-workspace.yaml')) ||
112
- fs.existsSync(path.join(cur, 'nx.json'))) {
111
+ const hasConfig = ConfigLoader.CONFIG_FILE_NAMES.some((name) => fs.existsSync(path.join(cur, name)));
112
+ if (hasConfig || fs.existsSync(path.join(cur, 'pnpm-workspace.yaml')) || fs.existsSync(path.join(cur, 'nx.json'))) {
113
113
  rootDir = cur;
114
114
  break;
115
115
  }
@@ -289,6 +289,7 @@ export async function addCommand(moduleNameArg, options = {}) {
289
289
  copyRecursive(sampleE2eSrc, targetE2eDir, {
290
290
  'playground-e2e': e2eProjectName,
291
291
  'packages/playground/e2e': path.relative(rootDir, targetE2eDir).replace(/\\/g, '/'),
292
+ 'testspectra:scope:playground': `testspectra:scope:${featureName}`,
292
293
  'scope:playground': `scope:${featureName}`,
293
294
  });
294
295
  // Adjust project.json
@@ -300,7 +301,7 @@ export async function addCommand(moduleNameArg, options = {}) {
300
301
  pObj.sourceRoot = path.relative(rootDir, targetE2eDir).replace(/\\/g, '/');
301
302
  pObj.targets.e2e.options.cwd = path.relative(rootDir, targetE2eDir).replace(/\\/g, '/');
302
303
  pObj.targets['type-check'].options.cwd = '.';
303
- pObj.tags = [`scope:${featureName}`, 'type:e2e'];
304
+ pObj.tags = ['testspectra:e2e', `testspectra:scope:${featureName}`];
304
305
  fs.writeFileSync(projJsonPath, JSON.stringify(pObj, null, 2), 'utf-8');
305
306
  }
306
307
  catch { }
@@ -32,6 +32,7 @@ export async function devicesCommand(options = {}) {
32
32
  cwd,
33
33
  env: getRunnerEnv(),
34
34
  stdio: 'inherit',
35
+ windowsHide: true,
35
36
  });
36
37
  child.on('close', (code) => {
37
38
  if (code === 0) {
@@ -0,0 +1,4 @@
1
+ export interface DocsCommandOptions {
2
+ cwd?: string;
3
+ }
4
+ export declare function docsUpdateCommand(options?: DocsCommandOptions): void;
@@ -0,0 +1,17 @@
1
+ import path from 'path';
2
+ import chalk from 'chalk';
3
+ import * as p from '@clack/prompts';
4
+ import { generateArchitectureDoc } from '../generator/architecture-doc-generator.js';
5
+ function resolveBaseDir(options = {}) {
6
+ return options.cwd ? path.resolve(options.cwd) : process.cwd();
7
+ }
8
+ export function docsUpdateCommand(options = {}) {
9
+ const cwd = resolveBaseDir(options);
10
+ const result = generateArchitectureDoc(cwd);
11
+ if (result.mode === 'nx') {
12
+ p.log.success(chalk.green(`ARCHITECTURE.md regenerated (Nx/monorepo mode, ${result.featureCount ?? 0} feature module(s) detected).`));
13
+ }
14
+ else {
15
+ p.log.success(chalk.green('ARCHITECTURE.md regenerated (standalone mode).'));
16
+ }
17
+ }
@@ -13,9 +13,17 @@ export interface SystemCheckResult {
13
13
  missing_count: number;
14
14
  dependencies: DependencyStatus[];
15
15
  }
16
- export declare function runSystemChecks(cwd?: string): Promise<SystemCheckResult>;
16
+ export interface SystemCheckOptions {
17
+ /** Category filter: `core`, `web`, or `mobile` (default: all). */
18
+ scope?: string;
19
+ /** Comma-separated specific dependency keys, e.g. `chrome` or `chrome,adb` (takes precedence over `scope`). */
20
+ only?: string;
21
+ }
22
+ export declare function runSystemChecks(cwd?: string, options?: SystemCheckOptions): Promise<SystemCheckResult>;
17
23
  export declare function doctorCommand(options?: {
18
24
  fix?: boolean;
19
25
  json?: boolean;
20
26
  verbose?: boolean;
27
+ scope?: string;
28
+ only?: string;
21
29
  }): Promise<void>;
@@ -9,9 +9,16 @@ function getRunnerEnv() {
9
9
  TEST_SPECTRA_DRIVER_CACHE: globalDriversDir,
10
10
  };
11
11
  }
12
- export async function runSystemChecks(cwd = process.cwd()) {
12
+ export async function runSystemChecks(cwd = process.cwd(), options = {}) {
13
13
  const binPath = RustCoreBridge.resolveBinaryPath();
14
- const stdout = execFileSync(binPath, ['doctor', '--json'], {
14
+ const args = ['doctor', '--json'];
15
+ if (options.scope) {
16
+ args.push('--scope', options.scope);
17
+ }
18
+ if (options.only) {
19
+ args.push('--only', options.only);
20
+ }
21
+ const stdout = execFileSync(binPath, args, {
15
22
  cwd,
16
23
  env: getRunnerEnv(),
17
24
  encoding: 'utf8',
@@ -29,11 +36,17 @@ export async function doctorCommand(options = {}) {
29
36
  if (options.verbose) {
30
37
  args.push('--verbose');
31
38
  }
39
+ if (options.scope) {
40
+ args.push('--scope', options.scope);
41
+ }
42
+ if (options.only) {
43
+ args.push('--only', options.only);
44
+ }
32
45
  if (options.fix) {
33
46
  args.push('--fix');
34
47
  }
35
48
  if (options.json) {
36
- const result = await runSystemChecks(cwd);
49
+ const result = await runSystemChecks(cwd, { scope: options.scope, only: options.only });
37
50
  console.log(JSON.stringify(result, null, 2));
38
51
  return;
39
52
  }
@@ -42,6 +55,7 @@ export async function doctorCommand(options = {}) {
42
55
  cwd,
43
56
  env: getRunnerEnv(),
44
57
  stdio: 'inherit',
58
+ windowsHide: true,
45
59
  });
46
60
  child.on('close', (code) => {
47
61
  if (code === 0 || options.fix) {
@@ -6,6 +6,7 @@ import chalk from 'chalk';
6
6
  import { ConfigLoader } from '../config/loader.js';
7
7
  import { TypeGenerator } from '../types/generator.js';
8
8
  import { TsConfigGenerator } from '../generator/tsconfig-generator.js';
9
+ import { generateArchitectureDoc } from '../generator/architecture-doc-generator.js';
9
10
  function parsePnpmWorkspaceGlobs(content) {
10
11
  const lines = content.split('\n');
11
12
  const globs = [];
@@ -460,6 +461,8 @@ export async function initCommand(options = {}) {
460
461
  (typeof rootPkg.devDependencies['@testspectra/matchers'] === 'string' &&
461
462
  rootPkg.devDependencies['@testspectra/matchers'].startsWith('link:')))
462
463
  rootPkg.devDependencies['@testspectra/matchers'] = cliDepVersion;
464
+ if (!rootPkg.devDependencies['nx'])
465
+ rootPkg.devDependencies['nx'] = '^20.8.4';
463
466
  if (!rootPkg.devDependencies['typescript'])
464
467
  rootPkg.devDependencies['typescript'] = '^5.4.5';
465
468
  if (!rootPkg.devDependencies['@wdio/cli'])
@@ -508,6 +511,7 @@ export async function initCommand(options = {}) {
508
511
  copyRecursive(sampleE2eSrc, targetE2eDir, {
509
512
  'playground-e2e': e2eProjectName,
510
513
  'packages/playground/e2e': path.relative(cwd, targetE2eDir).replace(/\\/g, '/'),
514
+ 'testspectra:scope:playground': `testspectra:scope:${featureName}`,
511
515
  'scope:playground': `scope:${featureName}`,
512
516
  });
513
517
  // Adjust project.json
@@ -519,7 +523,7 @@ export async function initCommand(options = {}) {
519
523
  pObj.sourceRoot = path.relative(cwd, targetE2eDir).replace(/\\/g, '/');
520
524
  pObj.targets.e2e.options.cwd = path.relative(cwd, targetE2eDir).replace(/\\/g, '/');
521
525
  pObj.targets['type-check'].options.cwd = '.';
522
- pObj.tags = [`scope:${featureName}`, 'type:e2e'];
526
+ pObj.tags = ['testspectra:e2e', `testspectra:scope:${featureName}`];
523
527
  fs.writeFileSync(projJsonPath, JSON.stringify(pObj, null, 2), 'utf-8');
524
528
  }
525
529
  catch { }
@@ -557,137 +561,7 @@ export async function initCommand(options = {}) {
557
561
  // 7. Generate Ambient Types in ROOT only
558
562
  TypeGenerator.writeDeclarationFiles(cwd);
559
563
  ensureVsCodeExtensions(cwd);
560
- const archDocContent = `# TestSpectra Enterprise Monorepo Architecture
561
-
562
- This workspace uses TestSpectra's **"Centralized Configuration, Distributed Implementation"** model for automated cross-platform testing.
563
-
564
- ---
565
-
566
- ## 1. Directory & File Overview
567
-
568
- ### Centralized Root Elements
569
- - \`./spectra.config.ts\`: Single source of truth for runtime configurations (Base URL, Appium devices, browser targets, timeouts).
570
- - \`./.testspectra/\`: Local test project cache, runtime metadata, auto-generated master TSConfig (\`.testspectra/tsconfig.json\`), platform sub-configs (\`.testspectra/tsconfig/\`), and universal ambient types (\`.testspectra/types/\`). Global binaries and drivers are managed at \`~/.testspectra/drivers/\`.
571
- - \`./nx.json\`: Nx target defaults with execution caching and inputs.
572
- - \`./pnpm-workspace.yaml\`: Monorepo package glob definitions.
573
- - \`./tsconfig.json\`: Solution-style TypeScript orchestrator referencing \`./.testspectra/tsconfig.json\`.
574
-
575
- ### Centralized Shared Testing Library (\`./${sharedTestingRelPath}\`)
576
- Provides cross-feature reusable test entities with **100% zero-import global resolution**:
577
- - \`page-objects/\`: Shared Page Object models (e.g. NavigationBar, AppHeader).
578
- - \`steps/\`: Cross-feature business step flows (e.g. \`Step.loginAsAdmin()\`).
579
- - \`actions/\`: Custom atomic actions (e.g. \`Spectra.dismissBanner()\`).
580
- - \`fixtures/\`: Common test data and environment configurations (e.g. \`Fixture.appConfig\`).
581
-
582
- ### Distributed Feature E2E Modules (${featureE2eDirs.length} Features)
583
- ${featureE2eDirs
584
- .map((d) => {
585
- const rel = path.relative(cwd, d);
586
- const name = path.basename(path.dirname(d));
587
- const e2eName = `${name}-${e2eFolderName}`;
588
- return `- \`./${rel}\` (**${name}**, Nx Project: \`${e2eName}\`):
589
- - \`specs/\`: Feature test cases (\`specs/<SuiteName>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
590
- - \`page-objects/\`: Feature-specific Page Objects (e.g. \`LoginPage\`, \`ProductPage\`).
591
- - \`project.json\`: Nx targets (\`e2e\`, \`type-check\`) supporting configurations (\`--configuration=android\`, \`--configuration=ios\`, \`--configuration=headless\`).`;
592
- })
593
- .join('\n')}
594
-
595
- ---
596
-
597
- ## 2. Zero-Import Consumption Flow & Mechanics
598
-
599
- TestSpectra completely eliminates boilerplate \`import\` statements across all test specs, steps, and page objects.
600
-
601
- ### How It Works:
602
- 1. **Centralized Ambient Aggregation**:
603
- TestSpectra Language Service Plugin & CLI automatically scan:
604
- - **Local Feature Entities**: \`<feature>/${e2eFolderName}/page-objects/\`, \`<feature>/${e2eFolderName}/steps/\`, \`<feature>/${e2eFolderName}/actions/\`
605
- - **Shared Library Entities**: \`./${sharedTestingRelPath}/page-objects/\`, \`./${sharedTestingRelPath}/steps/\`, \`./${sharedTestingRelPath}/actions/\`, \`./${sharedTestingRelPath}/fixtures/\`
606
- 2. **Ambient Typing Generation**:
607
- These are compiled into \`.testspectra/types/web.d.ts\`, \`android.d.ts\`, \`ios.d.ts\`, \`fixtures.d.ts\`.
608
- 3. **Instant IDE Autocomplete & Zero Clutter**:
609
- Specs consume both local feature objects and shared library utilities globally.
610
-
611
- ### Code Example:
612
- \`\`\`typescript
613
- // packages/features/auth/e2e/specs/Auth/TC-AUTH-01/web.test.ts
614
- // 🌟 NOTICE: 100% Zero-Import & Flat Execution! (No import statement, no describe wrapper)
615
-
616
- it("should navigate via shared header and login with local POM", async () => {
617
- // 1. Consumed from Shared Testing Library (${sharedTestingRelPath}/page-objects/NavigationBar)
618
- await NavigationBar.goToLogin();
619
-
620
- // 2. Consumed from Shared Testing Library (${sharedTestingRelPath}/steps/loginAsAdmin)
621
- await Step.loginAsAdmin();
622
-
623
- // 3. Consumed from Local Feature POM (page-objects/LoginPage)
624
- await LoginPage.flashAlert.shouldBeVisible();
625
- await LoginPage.flashAlert.shouldContainText("Welcome");
626
-
627
- // 4. Consumed from Shared Testing Library Custom Action (${sharedTestingRelPath}/actions/dismissBanner)
628
- await Spectra.dismissBanner();
629
- });
630
- \`\`\`
631
-
632
- ---
633
-
634
- ## 3. How to Run Tests
635
-
636
- You can execute tests either from the **Monorepo Root via Nx** or directly inside each **Feature Directory via CLI**:
637
-
638
- ### Option A: From Root Monorepo via Nx (Recommended for CI & Team Workflows)
639
-
640
- \`\`\`bash
641
- # 1. Run E2E for a SPECIFIC feature module (e.g. auth)
642
- pnpm nx run auth-${e2eFolderName}:e2e
643
-
644
- # 2. Run E2E for a specific feature on ANDROID or IOS
645
- pnpm nx run auth-${e2eFolderName}:e2e --configuration=android
646
- pnpm nx run auth-${e2eFolderName}:e2e --configuration=ios
647
-
648
- # 3. Run E2E for a specific feature in HEADLESS browser mode
649
- pnpm nx run auth-${e2eFolderName}:e2e --configuration=headless
650
-
651
- # 4. Run ALL feature E2E suites across the entire monorepo in parallel
652
- pnpm nx run-many -t e2e
653
-
654
- # 5. Run only E2E tests for features modified in current Git branch / PR
655
- pnpm nx affected -t e2e
656
- \`\`\`
657
-
658
- ### Option B: From Inside the Feature Directory (Direct CLI)
659
-
660
- \`\`\`bash
661
- # Navigate to the feature e2e folder
662
- cd ${featureE2eDirs.length > 0 ? path.relative(cwd, featureE2eDirs[0]).replace(/\\/g, '/') : `modules/auth/${e2eFolderName}`}
663
-
664
- # Run all specs in this feature
665
- pnpm spectra run
666
-
667
- # Run a specific test case file
668
- pnpm spectra run specs/Auth/TC-AUTH-01/web.test.ts
669
-
670
- # Target Android device or emulator
671
- pnpm spectra run --target android
672
-
673
- # Run in headed / interactive browser mode
674
- pnpm spectra run --no-headless
675
- \`\`\`
676
-
677
- ---
678
-
679
- ## 4. Type Checking & Validation
680
-
681
- \`\`\`bash
682
- # Type check all E2E projects via Nx
683
- pnpm nx run-many -t type-check
684
-
685
- # Or standard TypeScript project references build from root
686
- pnpm type-check
687
- # or: npx tsc -b
688
- \`\`\`
689
- `;
690
- fs.writeFileSync(path.join(cwd, 'ARCHITECTURE.md'), archDocContent, 'utf-8');
564
+ generateArchitectureDoc(cwd);
691
565
  // 8. Ensure root .gitignore ignores .testspectra/ and *.tsbuildinfo
692
566
  const rootGitignorePath = path.join(cwd, '.gitignore');
693
567
  const ignoreEntries = ['.testspectra/', '*.tsbuildinfo', '.nx/cache'];
@@ -741,34 +615,7 @@ pnpm type-check
741
615
  TypeGenerator.writeDeclarationFiles(cwd);
742
616
  ensureVsCodeExtensions(cwd);
743
617
  // Standalone Architecture Documentation
744
- const standaloneArchDoc = `# TestSpectra Project Architecture
745
-
746
- This project is built with the TestSpectra testing framework.
747
-
748
- ## Structure & File Map
749
- - \`./spectra.config.ts\`: Typed runner configuration.
750
- - \`./specs/\`: Layered test cases (\`specs/<Suite>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
751
- - \`./page-objects/\`: Page Object models per platform.
752
- - \`./steps/\`: Business flows accessible globally via \`Step.*\`.
753
- - \`./actions/\`: Atomic actions accessible globally via \`Spectra.*\`.
754
- - \`./fixtures/\`: JSON fixtures accessible globally via \`Fixture.*\`.
755
- - \`./global-hooks/\`: Global suite lifecycle hooks.
756
- - \`./.testspectra/\`: Auto-generated ambient typings and local runtime cache.
757
-
758
- ## Execution
759
- \`\`\`bash
760
- # Run web test suite
761
- pnpm test
762
-
763
- # Run Android / iOS
764
- pnpm spectra run --target android
765
- pnpm spectra run --target ios
766
-
767
- # Type check
768
- pnpm type-check
769
- \`\`\`
770
- `;
771
- fs.writeFileSync(path.join(cwd, 'ARCHITECTURE.md'), standaloneArchDoc, 'utf-8');
618
+ generateArchitectureDoc(cwd);
772
619
  // Safely update root README.md (do not overwrite existing content)
773
620
  const standaloneReadmePath = path.join(cwd, 'README.md');
774
621
  const standaloneArchSection = `\n## E2E Testing Architecture (TestSpectra)\n\nDetailed test architecture and folder map are documented in: \nšŸ‘‰ **[ARCHITECTURE.md](./ARCHITECTURE.md)**\n\n- **Run tests**: \`pnpm test\`\n- **Type-check**: \`pnpm type-check\`\n`;
@@ -17,6 +17,9 @@ export async function installCommand(item, options = {}) {
17
17
  if (item) {
18
18
  args.push(item);
19
19
  }
20
+ if (options.force) {
21
+ args.push('--force');
22
+ }
20
23
  return new Promise((resolve) => {
21
24
  let child;
22
25
  if (binPath === 'cargo') {
@@ -34,6 +37,7 @@ export async function installCommand(item, options = {}) {
34
37
  cwd: workspaceRoot,
35
38
  env: runnerEnv,
36
39
  stdio: 'inherit',
40
+ windowsHide: true,
37
41
  });
38
42
  }
39
43
  else {
@@ -41,6 +45,7 @@ export async function installCommand(item, options = {}) {
41
45
  cwd,
42
46
  env: runnerEnv,
43
47
  stdio: 'inherit',
48
+ windowsHide: true,
44
49
  });
45
50
  }
46
51
  child.on('close', (code) => {
@@ -14,6 +14,7 @@ export async function licenseCommand(action = 'status', key, options = {}) {
14
14
  const child = spawn(binPath, args, {
15
15
  stdio: 'inherit',
16
16
  env: process.env,
17
+ windowsHide: true,
17
18
  });
18
19
  child.on('close', (code) => {
19
20
  if (code === 0) {
@@ -1,6 +1,8 @@
1
1
  export interface RunCommandOptions {
2
2
  spec?: string;
3
3
  target?: 'web' | 'android' | 'ios' | 'common' | 'mobile';
4
+ host?: string;
5
+ baseUrl?: string;
4
6
  device?: string;
5
7
  devices?: string;
6
8
  allDevices?: boolean;