@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.
- package/README.md +11 -8
- package/dist/.tsbuildinfo +1 -1
- package/dist/commands/__tests__/doctor-filter.test.d.ts +1 -0
- package/dist/commands/__tests__/doctor-filter.test.js +37 -0
- package/dist/commands/__tests__/test-error-streaming.test.d.ts +1 -0
- package/dist/commands/__tests__/test-error-streaming.test.js +85 -0
- package/dist/commands/__tests__/test-scaffolding.test.d.ts +1 -0
- package/dist/commands/__tests__/test-scaffolding.test.js +32 -0
- package/dist/commands/__tests__/upgrade.test.d.ts +1 -0
- package/dist/commands/__tests__/upgrade.test.js +95 -0
- package/dist/commands/add.js +5 -4
- package/dist/commands/devices.js +1 -0
- package/dist/commands/docs.d.ts +4 -0
- package/dist/commands/docs.js +17 -0
- package/dist/commands/doctor.d.ts +9 -1
- package/dist/commands/doctor.js +17 -3
- package/dist/commands/init.js +7 -160
- package/dist/commands/install.js +5 -0
- package/dist/commands/license.js +1 -0
- package/dist/commands/run.d.ts +2 -0
- package/dist/commands/run.js +22 -0
- package/dist/commands/test.d.ts +13 -0
- package/dist/commands/test.js +115 -21
- package/dist/commands/upgrade.d.ts +12 -0
- package/dist/commands/upgrade.js +197 -0
- package/dist/config/schema.d.ts +53 -0
- package/dist/config/schema.js +2 -0
- package/dist/generator/__tests__/tsconfig-isolation.test.js +2 -1
- package/dist/generator/__tests__/type-generator.test.js +38 -0
- package/dist/generator/architecture-doc-generator.d.ts +14 -0
- package/dist/generator/architecture-doc-generator.js +80 -0
- package/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.js +1 -0
- package/dist/generator/tsconfig-generator.js +1 -1
- package/dist/generator/type-generator.d.ts +5 -2
- package/dist/generator/type-generator.js +14 -17
- package/dist/index.js +59 -16
- package/dist/linter/__tests__/shared-lib-boundary.test.js +15 -15
- package/dist/linter/discovery.d.ts +3 -3
- package/dist/linter/discovery.js +7 -7
- package/dist/linter/schemas/spec.schema.d.ts +6 -6
- package/dist/runner/bridge.d.ts +1 -1
- package/dist/runner/bridge.js +67 -16
- package/dist/runner/reporter.d.ts +1 -0
- package/dist/runner/reporter.js +12 -6
- package/dist/utils/__tests__/dev-server-manager.test.d.ts +1 -0
- package/dist/utils/__tests__/dev-server-manager.test.js +72 -0
- package/dist/utils/background-update-check.d.ts +1 -0
- package/dist/utils/background-update-check.js +43 -0
- package/dist/utils/dependency-updates.d.ts +15 -0
- package/dist/utils/dependency-updates.js +107 -0
- package/dist/utils/dev-server-manager.d.ts +40 -0
- package/dist/utils/dev-server-manager.js +257 -0
- package/dist/utils/update-notifier.d.ts +2 -0
- package/dist/utils/update-notifier.js +67 -0
- package/package.json +10 -9
- package/templates/default/package.json +2 -2
- package/templates/docs/ARCHITECTURE.default.md +26 -0
- package/templates/docs/ARCHITECTURE.nx.md +147 -0
- 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 +947 -0
- package/templates/nx/.nx/workspace-data/d/server-process.json +1 -1
- package/templates/nx/.nx/workspace-data/file-map.json +172 -186
- package/templates/nx/.nx/workspace-data/lockfile.hash +1 -1
- package/templates/nx/.nx/workspace-data/nx_files.nxt +0 -0
- package/templates/nx/.nx/workspace-data/parsed-lock-file.json +81 -130
- package/templates/nx/.nx/workspace-data/project-graph.json +90 -144
- package/templates/nx/.nx/workspace-data/source-maps.json +336 -0
- package/templates/nx/package.json +3 -3
- package/templates/nx/packages/matchers/e2e/project.json +2 -2
- package/templates/nx/packages/playground/e2e/project.json +2 -2
- package/templates/nx/pnpm-lock.yaml +191 -214
- package/templates/nx/shared/testing/project.json +1 -2
- package/templates/nx/spectra.config.ts +13 -0
- package/templates/react-component/package.json +3 -3
- package/templates/react-component/page-objects/BadgeComponent/web.ts +4 -4
- package/templates/react-component/page-objects/ButtonComponent/web.ts +3 -3
- package/templates/react-component/page-objects/InputComponent/web.ts +1 -1
- package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/web.test.tsx +0 -3
- package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/web.test.tsx +0 -9
- package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/web.test.tsx +1 -1
- package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/web.test.tsx +4 -8
- package/templates/react-component/spectra.config.ts +0 -10
- package/templates/react-component/src/components/Badge/Badge.tsx +3 -3
- package/templates/react-component/src/components/Button/Button.tsx +5 -3
- package/templates/react-component/src/components/Input/Input.tsx +2 -3
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { TsConfigGenerator } from './tsconfig-generator.js';
|
|
5
|
+
function resolveDocsTemplateDir() {
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const candidates = [
|
|
9
|
+
path.resolve(__dirname, '../templates/docs'),
|
|
10
|
+
path.resolve(__dirname, '../../templates/docs'),
|
|
11
|
+
path.resolve(__dirname, '../../../templates/docs'),
|
|
12
|
+
];
|
|
13
|
+
return candidates.find((d) => fs.existsSync(d)) ?? candidates[candidates.length - 1];
|
|
14
|
+
}
|
|
15
|
+
function renderArchitectureDoc(templatePath, replacements) {
|
|
16
|
+
let content = fs.readFileSync(templatePath, 'utf-8');
|
|
17
|
+
for (const [token, value] of Object.entries(replacements)) {
|
|
18
|
+
content = content.replaceAll(token, value);
|
|
19
|
+
}
|
|
20
|
+
return content;
|
|
21
|
+
}
|
|
22
|
+
/** Reads a feature e2e dir's project.json for its Nx project name, falling back to `<parentDirName>-<e2eDirName>`. */
|
|
23
|
+
function resolveNxProjectName(featureDir) {
|
|
24
|
+
const parentName = path.basename(path.dirname(featureDir));
|
|
25
|
+
const fallback = `${parentName}-${path.basename(featureDir)}`;
|
|
26
|
+
const projJsonPath = path.join(featureDir, 'project.json');
|
|
27
|
+
if (!fs.existsSync(projJsonPath))
|
|
28
|
+
return fallback;
|
|
29
|
+
try {
|
|
30
|
+
const pObj = JSON.parse(fs.readFileSync(projJsonPath, 'utf-8'));
|
|
31
|
+
return typeof pObj.name === 'string' && pObj.name ? pObj.name : fallback;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return fallback;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function buildFeatureModulesSection(cwd, featureE2eDirs) {
|
|
38
|
+
return featureE2eDirs
|
|
39
|
+
.map((d) => {
|
|
40
|
+
const rel = path.relative(cwd, d).replace(/\\/g, '/');
|
|
41
|
+
const featureName = path.basename(path.dirname(d));
|
|
42
|
+
const e2eName = resolveNxProjectName(d);
|
|
43
|
+
return `- \`./${rel}\` (**${featureName}**, Nx Project: \`${e2eName}\`):
|
|
44
|
+
- \`specs/\`: Feature test cases (\`specs/<SuiteName>/<CaseId>/\` with \`web.test.ts\`, \`android.test.ts\`, \`ios.test.ts\`).
|
|
45
|
+
- \`page-objects/\`: Feature-specific Page Objects (e.g. \`LoginPage\`, \`ProductPage\`).
|
|
46
|
+
- \`project.json\`: Nx targets (\`e2e\`, \`type-check\`) supporting configurations (\`--configuration=android\`, \`--configuration=ios\`, \`--configuration=headless\`).`;
|
|
47
|
+
})
|
|
48
|
+
.join('\n');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* (Re)generates `ARCHITECTURE.md` from the current on-disk workspace state — no prompts, no other
|
|
52
|
+
* scaffolding side effects. Nx/monorepo mode is auto-detected via `TsConfigGenerator.getEntityScopes`
|
|
53
|
+
* (the same shared/feature discovery `sync-types` already relies on), so this stays accurate after
|
|
54
|
+
* features are added/removed/renamed without needing to re-run `spectra init`.
|
|
55
|
+
*/
|
|
56
|
+
export function generateArchitectureDoc(cwd) {
|
|
57
|
+
const docsTemplateDir = resolveDocsTemplateDir();
|
|
58
|
+
const destPath = path.join(cwd, 'ARCHITECTURE.md');
|
|
59
|
+
const scopes = TsConfigGenerator.getEntityScopes(cwd);
|
|
60
|
+
const isNxMode = scopes.length > 0 || fs.existsSync(path.join(cwd, 'nx.json'));
|
|
61
|
+
if (!isNxMode) {
|
|
62
|
+
fs.copyFileSync(path.join(docsTemplateDir, 'ARCHITECTURE.default.md'), destPath);
|
|
63
|
+
return { mode: 'default', path: destPath };
|
|
64
|
+
}
|
|
65
|
+
const sharedScope = scopes.find((s) => s.isShared);
|
|
66
|
+
const featureE2eDirs = scopes.filter((s) => !s.isShared).map((s) => s.dir);
|
|
67
|
+
const sharedTestingRelPath = sharedScope ? path.relative(cwd, sharedScope.dir).replace(/\\/g, '/') : 'shared/testing';
|
|
68
|
+
const e2eFolderName = featureE2eDirs.length > 0 ? path.basename(featureE2eDirs[0]) : 'e2e';
|
|
69
|
+
const content = renderArchitectureDoc(path.join(docsTemplateDir, 'ARCHITECTURE.nx.md'), {
|
|
70
|
+
__SHARED_TESTING_REL_PATH__: sharedTestingRelPath,
|
|
71
|
+
__FEATURE_COUNT__: String(featureE2eDirs.length),
|
|
72
|
+
__FEATURE_MODULES_SECTION__: buildFeatureModulesSection(cwd, featureE2eDirs),
|
|
73
|
+
__E2E_FOLDER_NAME__: e2eFolderName,
|
|
74
|
+
__SAMPLE_FEATURE_E2E_PATH__: featureE2eDirs.length > 0
|
|
75
|
+
? path.relative(cwd, featureE2eDirs[0]).replace(/\\/g, '/')
|
|
76
|
+
: `modules/auth/${e2eFolderName}`,
|
|
77
|
+
});
|
|
78
|
+
fs.writeFileSync(destPath, content, 'utf-8');
|
|
79
|
+
return { mode: 'nx', path: destPath, sharedTestingRelPath, featureCount: featureE2eDirs.length };
|
|
80
|
+
}
|
package/dist/generator/index.js
CHANGED
|
@@ -9,8 +9,11 @@ export interface EntityScope {
|
|
|
9
9
|
* Discovers all feature directories and shared library directories.
|
|
10
10
|
* Standard discovery hierarchy:
|
|
11
11
|
* 1. Nx / Monorepo Project Descriptors (`project.json`):
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
12
|
+
* - tags: ["testspectra:shared"] => Shared Library Scope (isShared: true)
|
|
13
|
+
* - tags: ["testspectra:e2e"] or ["testspectra:scope:<name>"] => Feature Scope (isShared: false)
|
|
14
|
+
* - Generic Nx libraries/apps without testspectra tags are not TestSpectra scopes and recursion
|
|
15
|
+
* continues into their subdirectories so nested e2e projects (e.g. `packages/features/auth/e2e`)
|
|
16
|
+
* are discovered.
|
|
14
17
|
* 2. Explicit User Configuration (`tsconfig.spectra.shared.json`):
|
|
15
18
|
* - Custom include path for shared testing utilities
|
|
16
19
|
* 3. Dynamic Workspace Filesystem Discovery (Fallback for non-Nx / custom layouts):
|
|
@@ -13,8 +13,11 @@ export const PLATFORM_HIERARCHY = {
|
|
|
13
13
|
* Discovers all feature directories and shared library directories.
|
|
14
14
|
* Standard discovery hierarchy:
|
|
15
15
|
* 1. Nx / Monorepo Project Descriptors (`project.json`):
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
16
|
+
* - tags: ["testspectra:shared"] => Shared Library Scope (isShared: true)
|
|
17
|
+
* - tags: ["testspectra:e2e"] or ["testspectra:scope:<name>"] => Feature Scope (isShared: false)
|
|
18
|
+
* - Generic Nx libraries/apps without testspectra tags are not TestSpectra scopes and recursion
|
|
19
|
+
* continues into their subdirectories so nested e2e projects (e.g. `packages/features/auth/e2e`)
|
|
20
|
+
* are discovered.
|
|
18
21
|
* 2. Explicit User Configuration (`tsconfig.spectra.shared.json`):
|
|
19
22
|
* - Custom include path for shared testing utilities
|
|
20
23
|
* 3. Dynamic Workspace Filesystem Discovery (Fallback for non-Nx / custom layouts):
|
|
@@ -48,16 +51,9 @@ export function discoverEntityScopes(cwd) {
|
|
|
48
51
|
if (fs.existsSync(projectJsonPath)) {
|
|
49
52
|
try {
|
|
50
53
|
const pObj = JSON.parse(fs.readFileSync(projectJsonPath, 'utf-8'));
|
|
51
|
-
const projectType = pObj.projectType;
|
|
52
54
|
const tags = Array.isArray(pObj.tags) ? pObj.tags : [];
|
|
53
|
-
const isSharedLib =
|
|
54
|
-
|
|
55
|
-
tags.includes('type:library') ||
|
|
56
|
-
tags.includes('scope:shared');
|
|
57
|
-
const isE2eApp = projectType === 'application' ||
|
|
58
|
-
tags.includes('type:e2e') ||
|
|
59
|
-
tags.includes('type:app') ||
|
|
60
|
-
tags.some((t) => t.startsWith('scope:') && t !== 'scope:shared');
|
|
55
|
+
const isSharedLib = tags.includes('testspectra:shared');
|
|
56
|
+
const isE2eApp = tags.includes('testspectra:e2e') || tags.some((t) => t.startsWith('testspectra:scope:'));
|
|
61
57
|
if (isSharedLib) {
|
|
62
58
|
if (!scopes.some((s) => s.dir === dir)) {
|
|
63
59
|
scopes.push({ name: 'shared', dir, isShared: true });
|
|
@@ -65,9 +61,9 @@ export function discoverEntityScopes(cwd) {
|
|
|
65
61
|
return; // Do not recurse into subdirectories of an identified project
|
|
66
62
|
}
|
|
67
63
|
else if (isE2eApp) {
|
|
68
|
-
// Extract scope name from tags (e.g. "scope:matchers" => "matchers") or project name
|
|
69
|
-
const scopeTag = tags.find((t) => t.startsWith('
|
|
70
|
-
let featureName = scopeTag ? scopeTag.replace('scope:', '') : '';
|
|
64
|
+
// Extract scope name from tags (e.g. "testspectra:scope:matchers" => "matchers") or project name
|
|
65
|
+
const scopeTag = tags.find((t) => t.startsWith('testspectra:scope:'));
|
|
66
|
+
let featureName = scopeTag ? scopeTag.replace('testspectra:scope:', '') : '';
|
|
71
67
|
if (!featureName && pObj.name) {
|
|
72
68
|
featureName = pObj.name.replace(/-e2e$/, '').replace(/^e2e-/, '');
|
|
73
69
|
}
|
|
@@ -329,6 +325,9 @@ export class TypeGenerator {
|
|
|
329
325
|
const hierarchy = PLATFORM_HIERARCHY[platform];
|
|
330
326
|
let content = `// Auto-generated ambient declarations for TestSpectra [${platform.toUpperCase()}]\n`;
|
|
331
327
|
content += `// Managed automatically by TestSpectra Language Service Plugin.\n\n`;
|
|
328
|
+
content += `/// <reference types="@testspectra/matchers" />\n`;
|
|
329
|
+
content += `/// <reference path="./fixtures.d.ts" />\n`;
|
|
330
|
+
content += `/// <reference path="${envRefPath}" />\n\n`;
|
|
332
331
|
// TestSpectra's Rust-native orchestrator worker (core/orchestrator/src/worker/bdd_runner.ts)
|
|
333
332
|
// registers its own `it`/`test`/lifecycle-hook globals directly — there is no WDIO or Mocha
|
|
334
333
|
// runtime involved at all (not just for component testing; this is true across every
|
|
@@ -346,9 +345,7 @@ export class TypeGenerator {
|
|
|
346
345
|
// — the Rust orchestrator's BDD runtime has no `expect` global at all.
|
|
347
346
|
content += `declare const expect: import('@testspectra/react').ExpectStatic;\n`;
|
|
348
347
|
}
|
|
349
|
-
content +=
|
|
350
|
-
content += `/// <reference path="./fixtures.d.ts" />\n`;
|
|
351
|
-
content += `/// <reference path="${envRefPath}" />\n\n`;
|
|
348
|
+
content += `\n`;
|
|
352
349
|
// 1. Page Objects Global Declarations
|
|
353
350
|
const declaredPOMs = new Set();
|
|
354
351
|
for (const poDir of poDirs) {
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,13 @@ import { initCommand } from './commands/init.js';
|
|
|
7
7
|
import { installCommand } from './commands/install.js';
|
|
8
8
|
import { runCommand } from './commands/run.js';
|
|
9
9
|
import { testCommand } from './commands/test.js';
|
|
10
|
-
import {
|
|
10
|
+
import { upgradeCommand } from './commands/upgrade.js';
|
|
11
11
|
import { watchCommand } from './commands/watch.js';
|
|
12
12
|
import { syncTypesCommand } from './commands/sync-types.js';
|
|
13
13
|
import { refactorCommand } from './commands/refactor.js';
|
|
14
14
|
import { lintCommand } from './commands/lint.js';
|
|
15
15
|
import { licenseCommand } from './commands/license.js';
|
|
16
|
+
import { docsUpdateCommand } from './commands/docs.js';
|
|
16
17
|
import { skillsInitCommand, skillsListCommand, skillsAddCommand, skillsUpdateCommand, skillsRemoveCommand, } from './commands/skills.js';
|
|
17
18
|
export * from './config/schema.js';
|
|
18
19
|
export * from './config/loader.js';
|
|
@@ -24,10 +25,10 @@ export * from './types/generator.js';
|
|
|
24
25
|
export * from '@testspectra/matchers';
|
|
25
26
|
export function createCliProgram() {
|
|
26
27
|
const program = new Command();
|
|
27
|
-
program.name('spectra').description('TestSpectra
|
|
28
|
+
program.name('spectra').description('TestSpectra Cross-Platform Test Runner CLI').version('1.0.0');
|
|
28
29
|
program
|
|
29
30
|
.command('init')
|
|
30
|
-
.description('Initialize
|
|
31
|
+
.description('Initialize spectra.config.ts and project directories')
|
|
31
32
|
.option('-t, --template <template>', 'Project template: default, nx, react-component')
|
|
32
33
|
.option('-f, --force', 'Overwrite existing configuration if present')
|
|
33
34
|
.action(initCommand);
|
|
@@ -40,15 +41,16 @@ export function createCliProgram() {
|
|
|
40
41
|
program
|
|
41
42
|
.command('install [dependency]')
|
|
42
43
|
.description('Install missing testing dependencies, browser drivers, and workspace packages')
|
|
43
|
-
.option('-f, --force', '
|
|
44
|
+
.option('-f, --force', 'Remove existing artifacts and perform a clean reinstall of the dependency')
|
|
44
45
|
.addHelpText('after', `
|
|
45
46
|
Examples:
|
|
46
47
|
$ spectra install Install all missing required dependencies automatically
|
|
47
48
|
$ spectra install chrome Install Google Chrome for Testing & matching Chromedriver
|
|
48
49
|
$ spectra install adb Install Google Android SDK Platform Tools (ADB)
|
|
49
50
|
$ spectra install bun Install Bun runtime
|
|
50
|
-
$ spectra install android-
|
|
51
|
-
$ spectra install
|
|
51
|
+
$ spectra install android-agent Install Spectra Android Native Agent (spectra-agent.jar)
|
|
52
|
+
$ spectra install android-agent -f Clean reinstall Spectra Android Native Agent
|
|
53
|
+
$ spectra install packages Install TestSpectra CLI, Matchers & Android Agent packages`)
|
|
52
54
|
.action(installCommand);
|
|
53
55
|
program
|
|
54
56
|
.command('demo')
|
|
@@ -85,20 +87,31 @@ Examples:
|
|
|
85
87
|
.action(lintCommand);
|
|
86
88
|
program
|
|
87
89
|
.command('doctor')
|
|
88
|
-
.description('Verify local environment prerequisites (ADB, Spectra Android
|
|
90
|
+
.description('Verify local environment prerequisites (Bun, Git, ADB, Chrome, Spectra Android Agent, workspace packages)')
|
|
89
91
|
.option('-v, --verbose', 'Show full installation paths for all detected runtimes and packages')
|
|
92
|
+
.option('--scope <category>', 'Only check one category: core, web, mobile (default: all)')
|
|
93
|
+
.option('--only <keys>', 'Only check specific dependencies (comma-separated): bun, git, cli, chrome, matchers, adb, agent')
|
|
90
94
|
.option('--fix', 'Attempt automatic fix / download of missing tools')
|
|
91
95
|
.option('--json', 'Output diagnostic results as JSON')
|
|
92
96
|
.action(doctorCommand);
|
|
93
97
|
program
|
|
94
|
-
.command('
|
|
95
|
-
.
|
|
98
|
+
.command('upgrade [packages...]')
|
|
99
|
+
.alias('update')
|
|
100
|
+
.description('Upgrade TestSpectra ecosystem packages and system drivers to the latest versions')
|
|
96
101
|
.option('--check', 'Only check for available updates without installing')
|
|
97
|
-
.
|
|
102
|
+
.option('--packages-only', 'Only upgrade NPM packages in package.json')
|
|
103
|
+
.option('--drivers-only', 'Only upgrade system binaries and drivers (ADB, Agent, Chrome)')
|
|
104
|
+
.option('--json', 'Output the update check (packages + drivers) as JSON (implies --check, no changes applied)')
|
|
105
|
+
.addHelpText('after', `
|
|
106
|
+
Examples:
|
|
107
|
+
$ spectra upgrade Upgrade all packages and system drivers
|
|
108
|
+
$ spectra upgrade @testspectra/cli Upgrade only the CLI package
|
|
109
|
+
$ spectra upgrade @testspectra/cli @testspectra/matchers Upgrade specific packages
|
|
110
|
+
$ spectra upgrade --check Check what is outdated (packages + drivers)`)
|
|
111
|
+
.action(upgradeCommand);
|
|
98
112
|
program
|
|
99
113
|
.command('devices')
|
|
100
|
-
.description('List connected Android
|
|
101
|
-
.option('-t, --target <target>', 'Filter scope: android, ios, web, all', 'all')
|
|
114
|
+
.description('List connected Android devices (ADB)')
|
|
102
115
|
.option('--json', 'Output results as JSON')
|
|
103
116
|
.action(devicesCommand);
|
|
104
117
|
program
|
|
@@ -147,11 +160,19 @@ Examples:
|
|
|
147
160
|
.option('-w, --cwd <dir>', 'Custom workspace directory')
|
|
148
161
|
.option('-a, --agent <ids>', 'One-off override: comma-separated agent(s) to target, bypassing the saved "init" selection (claude, opencode, kilo, agents, gemini)')
|
|
149
162
|
.action(skillsRemoveCommand);
|
|
163
|
+
const docs = program.command('docs').description('Manage generated TestSpectra workspace documentation');
|
|
164
|
+
docs
|
|
165
|
+
.command('update')
|
|
166
|
+
.description('Regenerate ARCHITECTURE.md from the current workspace state, without re-running init')
|
|
167
|
+
.option('-w, --cwd <dir>', 'Custom workspace directory')
|
|
168
|
+
.action(docsUpdateCommand);
|
|
150
169
|
program
|
|
151
170
|
.command('run [paths...]')
|
|
152
171
|
.description('Execute test suite or individual test case')
|
|
153
172
|
.option('-s, --spec <path>', 'Spec file path to execute')
|
|
154
173
|
.option('-t, --target <target>', 'Target platform: web, android, ios, common', 'web')
|
|
174
|
+
.option('--host <name>', 'Target specific named host defined in spectra.config.ts (webConfig.hosts)')
|
|
175
|
+
.option('--base-url <url>', 'Override webConfig.baseUrl')
|
|
155
176
|
.option('-d, --device <device>', 'Target device name or UDID')
|
|
156
177
|
.option('--all-devices', 'Distribute test execution across all connected devices')
|
|
157
178
|
.option('--multi-device', 'Distribute test execution across all connected devices (alias for --all-devices)')
|
|
@@ -170,20 +191,42 @@ Examples:
|
|
|
170
191
|
.action(runCommand);
|
|
171
192
|
program
|
|
172
193
|
.command('test')
|
|
173
|
-
.description('Run React component tests via @testspectra/react
|
|
194
|
+
.description('Run React component tests via @testspectra/react')
|
|
195
|
+
.option('-r, --runner <engine>', 'Component test runner engine: spectra (default, native CDP) or vitest (Playwright browser mode)', 'spectra')
|
|
174
196
|
.option('-w, --cwd <dir>', 'Custom workspace directory')
|
|
175
197
|
.option('-s, --spec <path>', 'Spec file path (or substring filter) to execute')
|
|
176
198
|
.option('--headless', 'Run in headless mode (default)')
|
|
177
199
|
.option('--no-headless', 'Run in headed mode')
|
|
178
200
|
.option('--headed', 'Run the browser in visible GUI mode (alias for --no-headless)')
|
|
179
|
-
.option('--step-delay <ms>', 'Delay after each action/assertion in milliseconds (slow motion, for observing DOM transitions in --headed mode)')
|
|
201
|
+
.option('-d, --step-delay <ms>', 'Delay after each action/assertion in milliseconds (slow motion, for observing DOM transitions in --headed mode)')
|
|
180
202
|
.option('--delay <ms>', 'Alias for --step-delay')
|
|
181
|
-
.option('-c, --concurrency <number>', 'Run spec files sequentially (1) or in parallel (>1, default).
|
|
182
|
-
.option('-o, --output <path>', 'Write a
|
|
203
|
+
.option('-c, --concurrency <number>', 'Run spec files sequentially (1) or in parallel (>1, default).')
|
|
204
|
+
.option('-o, --output <path>', 'Write a JSON test report to this path')
|
|
183
205
|
.action(testCommand);
|
|
184
206
|
return program;
|
|
185
207
|
}
|
|
186
208
|
export async function runCli(args = process.argv) {
|
|
187
209
|
const program = createCliProgram();
|
|
188
210
|
await program.parseAsync(args);
|
|
211
|
+
// Commands whose stdout must stay machine-readable or is purely diagnostic never emit the
|
|
212
|
+
// interactive "update available" banner.
|
|
213
|
+
const isJson = args.includes('--json');
|
|
214
|
+
const silentCommands = [
|
|
215
|
+
'doctor',
|
|
216
|
+
'install',
|
|
217
|
+
'upgrade',
|
|
218
|
+
'update',
|
|
219
|
+
'license',
|
|
220
|
+
'devices',
|
|
221
|
+
'lint',
|
|
222
|
+
'sync-types',
|
|
223
|
+
'refactor',
|
|
224
|
+
'watch',
|
|
225
|
+
];
|
|
226
|
+
const isSilent = isJson || silentCommands.includes(program.args[0]);
|
|
227
|
+
const { checkUpdateInBackground, displayUpdateNotificationIfNeeded } = await import('./utils/update-notifier.js');
|
|
228
|
+
checkUpdateInBackground();
|
|
229
|
+
if (!isSilent) {
|
|
230
|
+
displayUpdateNotificationIfNeeded();
|
|
231
|
+
}
|
|
189
232
|
}
|
|
@@ -17,16 +17,16 @@ describe('Shared Library Boundary (testspectra/no-specs-in-shared-lib)', () => {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
describe('findSharedLibraryRoots()', () => {
|
|
20
|
-
it('discovers parent folders of project.json files containing
|
|
20
|
+
it('discovers parent folders of project.json files containing testspectra:shared', () => {
|
|
21
21
|
const sharedDir1 = path.join(tempDir, 'shared', 'testing');
|
|
22
22
|
const sharedDir2 = path.join(tempDir, 'libs', 'common-helpers');
|
|
23
23
|
const nonSharedDir = path.join(tempDir, 'packages', 'playground', 'e2e');
|
|
24
24
|
fs.mkdirSync(sharedDir1, { recursive: true });
|
|
25
25
|
fs.mkdirSync(sharedDir2, { recursive: true });
|
|
26
26
|
fs.mkdirSync(nonSharedDir, { recursive: true });
|
|
27
|
-
fs.writeFileSync(path.join(sharedDir1, 'project.json'), JSON.stringify({ name: 'shared-testing', tags: ['
|
|
28
|
-
fs.writeFileSync(path.join(sharedDir2, 'project.json'), JSON.stringify({ name: 'common-helpers', tags: ['
|
|
29
|
-
fs.writeFileSync(path.join(nonSharedDir, 'project.json'), JSON.stringify({ name: 'playground-e2e', tags: ['
|
|
27
|
+
fs.writeFileSync(path.join(sharedDir1, 'project.json'), JSON.stringify({ name: 'shared-testing', tags: ['testspectra:shared'] }));
|
|
28
|
+
fs.writeFileSync(path.join(sharedDir2, 'project.json'), JSON.stringify({ name: 'common-helpers', tags: ['testspectra:shared'] }));
|
|
29
|
+
fs.writeFileSync(path.join(nonSharedDir, 'project.json'), JSON.stringify({ name: 'playground-e2e', tags: ['testspectra:e2e', 'testspectra:scope:playground'] }));
|
|
30
30
|
const roots = findSharedLibraryRoots(tempDir);
|
|
31
31
|
expect(roots).toHaveLength(2);
|
|
32
32
|
expect(roots).toContain(sharedDir1);
|
|
@@ -35,12 +35,12 @@ describe('Shared Library Boundary (testspectra/no-specs-in-shared-lib)', () => {
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
describe('isInsideSharedLibrary()', () => {
|
|
38
|
-
it('returns true for files inside a project tagged with
|
|
38
|
+
it('returns true for files inside a project tagged with testspectra:shared in project.json', () => {
|
|
39
39
|
const sharedDir = path.join(tempDir, 'shared', 'testing');
|
|
40
40
|
fs.mkdirSync(sharedDir, { recursive: true });
|
|
41
41
|
fs.writeFileSync(path.join(sharedDir, 'project.json'), JSON.stringify({
|
|
42
42
|
name: 'shared-testing',
|
|
43
|
-
tags: ['
|
|
43
|
+
tags: ['testspectra:shared'],
|
|
44
44
|
}));
|
|
45
45
|
const stepFile = path.join(sharedDir, 'support', 'steps', 'web.step.ts');
|
|
46
46
|
const specFile = path.join(sharedDir, 'specs', 'TC-001', 'spec.md');
|
|
@@ -55,7 +55,7 @@ describe('Shared Library Boundary (testspectra/no-specs-in-shared-lib)', () => {
|
|
|
55
55
|
fs.mkdirSync(customLibDir, { recursive: true });
|
|
56
56
|
fs.writeFileSync(path.join(customLibDir, 'project.json'), JSON.stringify({
|
|
57
57
|
name: 'custom-common-lib',
|
|
58
|
-
tags: ['
|
|
58
|
+
tags: ['testspectra:shared'],
|
|
59
59
|
}));
|
|
60
60
|
const actionFile = path.join(customLibDir, 'support', 'actions', 'click.action.ts');
|
|
61
61
|
expect(isInsideSharedLibrary(actionFile)).toBe(true);
|
|
@@ -65,7 +65,7 @@ describe('Shared Library Boundary (testspectra/no-specs-in-shared-lib)', () => {
|
|
|
65
65
|
fs.mkdirSync(sharedAppDir, { recursive: true });
|
|
66
66
|
fs.writeFileSync(path.join(sharedAppDir, 'project.json'), JSON.stringify({
|
|
67
67
|
name: 'shared-app',
|
|
68
|
-
tags: ['
|
|
68
|
+
tags: ['testspectra:e2e', 'testspectra:scope:shared-app'],
|
|
69
69
|
}));
|
|
70
70
|
const specFile = path.join(sharedAppDir, 'specs', 'TC-001', 'spec.md');
|
|
71
71
|
expect(isInsideSharedLibrary(specFile)).toBe(false);
|
|
@@ -75,7 +75,7 @@ describe('Shared Library Boundary (testspectra/no-specs-in-shared-lib)', () => {
|
|
|
75
75
|
fs.mkdirSync(featureDir, { recursive: true });
|
|
76
76
|
fs.writeFileSync(path.join(featureDir, 'project.json'), JSON.stringify({
|
|
77
77
|
name: 'playground-e2e',
|
|
78
|
-
tags: ['
|
|
78
|
+
tags: ['testspectra:e2e', 'testspectra:scope:playground'],
|
|
79
79
|
}));
|
|
80
80
|
const specFile = path.join(featureDir, 'specs', 'TC-001', 'spec.md');
|
|
81
81
|
expect(isInsideSharedLibrary(specFile)).toBe(false);
|
|
@@ -91,7 +91,7 @@ describe('Shared Library Boundary (testspectra/no-specs-in-shared-lib)', () => {
|
|
|
91
91
|
fs.mkdirSync(sharedLibDir, { recursive: true });
|
|
92
92
|
fs.writeFileSync(path.join(sharedLibDir, 'project.json'), JSON.stringify({
|
|
93
93
|
name: 'shared-testing',
|
|
94
|
-
tags: ['
|
|
94
|
+
tags: ['testspectra:shared'],
|
|
95
95
|
}));
|
|
96
96
|
const sharedSpecDir = path.join(sharedLibDir, 'specs', 'TC-error');
|
|
97
97
|
fs.mkdirSync(sharedSpecDir, { recursive: true });
|
|
@@ -119,7 +119,7 @@ status: draft
|
|
|
119
119
|
fs.mkdirSync(sharedLibDir, { recursive: true });
|
|
120
120
|
fs.writeFileSync(path.join(sharedLibDir, 'project.json'), JSON.stringify({
|
|
121
121
|
name: 'shared-testing',
|
|
122
|
-
tags: ['
|
|
122
|
+
tags: ['testspectra:shared'],
|
|
123
123
|
}));
|
|
124
124
|
const sharedSuiteDir = path.join(sharedLibDir, 'support');
|
|
125
125
|
fs.mkdirSync(sharedSuiteDir, { recursive: true });
|
|
@@ -141,7 +141,7 @@ status: active
|
|
|
141
141
|
fs.mkdirSync(customLibDir, { recursive: true });
|
|
142
142
|
fs.writeFileSync(path.join(customLibDir, 'project.json'), JSON.stringify({
|
|
143
143
|
name: 'my-testing-utils',
|
|
144
|
-
tags: ['
|
|
144
|
+
tags: ['testspectra:shared'],
|
|
145
145
|
}));
|
|
146
146
|
const specDir = path.join(customLibDir, 'specs', 'TC-custom');
|
|
147
147
|
fs.mkdirSync(specDir, { recursive: true });
|
|
@@ -169,7 +169,7 @@ status: draft
|
|
|
169
169
|
fs.mkdirSync(featureDir, { recursive: true });
|
|
170
170
|
fs.writeFileSync(path.join(featureDir, 'project.json'), JSON.stringify({
|
|
171
171
|
name: 'playground-e2e',
|
|
172
|
-
tags: ['
|
|
172
|
+
tags: ['testspectra:e2e', 'testspectra:scope:playground'],
|
|
173
173
|
}));
|
|
174
174
|
const featureSpecDir = path.join(featureDir, 'specs', 'TC-001');
|
|
175
175
|
fs.mkdirSync(featureSpecDir, { recursive: true });
|
|
@@ -195,7 +195,7 @@ status: draft
|
|
|
195
195
|
fs.mkdirSync(sharedE2eDir, { recursive: true });
|
|
196
196
|
fs.writeFileSync(path.join(sharedE2eDir, 'project.json'), JSON.stringify({
|
|
197
197
|
name: 'shared-feature-e2e',
|
|
198
|
-
tags: ['
|
|
198
|
+
tags: ['testspectra:e2e', 'testspectra:scope:shared-feature'],
|
|
199
199
|
}));
|
|
200
200
|
const specDir = path.join(sharedE2eDir, 'specs', 'TC-001');
|
|
201
201
|
fs.mkdirSync(specDir, { recursive: true });
|
|
@@ -241,7 +241,7 @@ status: draft
|
|
|
241
241
|
fs.mkdirSync(sharedLibDir, { recursive: true });
|
|
242
242
|
fs.writeFileSync(path.join(sharedLibDir, 'project.json'), JSON.stringify({
|
|
243
243
|
name: 'shared-testing',
|
|
244
|
-
tags: ['
|
|
244
|
+
tags: ['testspectra:shared'],
|
|
245
245
|
}));
|
|
246
246
|
const sharedDir1 = path.join(sharedLibDir, 'specs', 'TC-001');
|
|
247
247
|
const sharedDir2 = path.join(sharedLibDir, 'specs', 'TC-002');
|
|
@@ -4,14 +4,14 @@ export interface WorkspaceAssets {
|
|
|
4
4
|
fixtures: Set<string>;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Scans a workspace directory for all `project.json` files that have
|
|
8
|
-
* "
|
|
7
|
+
* Scans a workspace directory for all `project.json` files that have the
|
|
8
|
+
* "testspectra:shared" tag, and returns their parent folder paths.
|
|
9
9
|
*/
|
|
10
10
|
export declare function findSharedLibraryRoots(workspaceDir: string): string[];
|
|
11
11
|
/**
|
|
12
12
|
* Resolves the root directory of a shared testing library if the file path is inside one.
|
|
13
13
|
* Determines shared library status based on `project.json` containing
|
|
14
|
-
*
|
|
14
|
+
* the "testspectra:shared" tag in ancestor directories,
|
|
15
15
|
* taking the parent folder of that `project.json` as the shared library root.
|
|
16
16
|
*/
|
|
17
17
|
export declare function getSharedLibraryRoot(filePath: string, workspaceDir?: string): string | null;
|
package/dist/linter/discovery.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { ConfigLoader } from '../config/loader.js';
|
|
3
4
|
/**
|
|
4
|
-
* Scans a workspace directory for all `project.json` files that have
|
|
5
|
-
* "
|
|
5
|
+
* Scans a workspace directory for all `project.json` files that have the
|
|
6
|
+
* "testspectra:shared" tag, and returns their parent folder paths.
|
|
6
7
|
*/
|
|
7
8
|
export function findSharedLibraryRoots(workspaceDir) {
|
|
8
9
|
const sharedRoots = [];
|
|
@@ -23,7 +24,7 @@ export function findSharedLibraryRoots(workspaceDir) {
|
|
|
23
24
|
const raw = fs.readFileSync(path.join(dir, entry.name), 'utf-8');
|
|
24
25
|
const parsed = JSON.parse(raw);
|
|
25
26
|
const tags = Array.isArray(parsed.tags) ? parsed.tags : [];
|
|
26
|
-
if (tags.includes('
|
|
27
|
+
if (tags.includes('testspectra:shared')) {
|
|
27
28
|
sharedRoots.push(dir);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -39,7 +40,7 @@ export function findSharedLibraryRoots(workspaceDir) {
|
|
|
39
40
|
/**
|
|
40
41
|
* Resolves the root directory of a shared testing library if the file path is inside one.
|
|
41
42
|
* Determines shared library status based on `project.json` containing
|
|
42
|
-
*
|
|
43
|
+
* the "testspectra:shared" tag in ancestor directories,
|
|
43
44
|
* taking the parent folder of that `project.json` as the shared library root.
|
|
44
45
|
*/
|
|
45
46
|
export function getSharedLibraryRoot(filePath, workspaceDir) {
|
|
@@ -67,7 +68,7 @@ export function getSharedLibraryRoot(filePath, workspaceDir) {
|
|
|
67
68
|
const raw = fs.readFileSync(projectJsonPath, 'utf-8');
|
|
68
69
|
const projectConfig = JSON.parse(raw);
|
|
69
70
|
const tags = Array.isArray(projectConfig.tags) ? projectConfig.tags : [];
|
|
70
|
-
if (tags.includes('
|
|
71
|
+
if (tags.includes('testspectra:shared')) {
|
|
71
72
|
return current;
|
|
72
73
|
}
|
|
73
74
|
return null;
|
|
@@ -96,8 +97,7 @@ export function isInsideSharedLibrary(filePath, workspaceDir) {
|
|
|
96
97
|
export function findProjectRoot(startDir) {
|
|
97
98
|
let current = path.resolve(startDir);
|
|
98
99
|
while (true) {
|
|
99
|
-
if (fs.existsSync(path.join(current,
|
|
100
|
-
fs.existsSync(path.join(current, 'spectra.config.js'))) {
|
|
100
|
+
if (ConfigLoader.CONFIG_FILE_NAMES.some((name) => fs.existsSync(path.join(current, name)))) {
|
|
101
101
|
return current;
|
|
102
102
|
}
|
|
103
103
|
const parent = path.dirname(current);
|
|
@@ -11,11 +11,11 @@ export declare const CoverageSchema: z.ZodObject<{
|
|
|
11
11
|
web: z.ZodOptional<z.ZodEnum<["automated", "manual", "unsupported"]>>;
|
|
12
12
|
mobile: z.ZodOptional<z.ZodEnum<["automated", "manual", "unsupported"]>>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
15
14
|
mobile?: "automated" | "manual" | "unsupported" | undefined;
|
|
16
|
-
}, {
|
|
17
15
|
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
16
|
+
}, {
|
|
18
17
|
mobile?: "automated" | "manual" | "unsupported" | undefined;
|
|
18
|
+
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
19
19
|
}>;
|
|
20
20
|
export declare const SpecFrontmatterSchema: z.ZodObject<{
|
|
21
21
|
id: z.ZodString;
|
|
@@ -27,11 +27,11 @@ export declare const SpecFrontmatterSchema: z.ZodObject<{
|
|
|
27
27
|
web: z.ZodOptional<z.ZodEnum<["automated", "manual", "unsupported"]>>;
|
|
28
28
|
mobile: z.ZodOptional<z.ZodEnum<["automated", "manual", "unsupported"]>>;
|
|
29
29
|
}, "strip", z.ZodTypeAny, {
|
|
30
|
-
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
31
30
|
mobile?: "automated" | "manual" | "unsupported" | undefined;
|
|
32
|
-
}, {
|
|
33
31
|
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
32
|
+
}, {
|
|
34
33
|
mobile?: "automated" | "manual" | "unsupported" | undefined;
|
|
34
|
+
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
35
35
|
}>>;
|
|
36
36
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
37
37
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -41,8 +41,8 @@ export declare const SpecFrontmatterSchema: z.ZodObject<{
|
|
|
41
41
|
priority: "Critical" | "High" | "Medium" | "Low";
|
|
42
42
|
caseType: "Positive" | "Negative" | "Edge";
|
|
43
43
|
coverage?: {
|
|
44
|
-
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
45
44
|
mobile?: "automated" | "manual" | "unsupported" | undefined;
|
|
45
|
+
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
46
46
|
} | undefined;
|
|
47
47
|
tags?: string[] | undefined;
|
|
48
48
|
}, {
|
|
@@ -52,8 +52,8 @@ export declare const SpecFrontmatterSchema: z.ZodObject<{
|
|
|
52
52
|
priority: "Critical" | "High" | "Medium" | "Low";
|
|
53
53
|
caseType: "Positive" | "Negative" | "Edge";
|
|
54
54
|
coverage?: {
|
|
55
|
-
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
56
55
|
mobile?: "automated" | "manual" | "unsupported" | undefined;
|
|
56
|
+
web?: "automated" | "manual" | "unsupported" | undefined;
|
|
57
57
|
} | undefined;
|
|
58
58
|
tags?: string[] | undefined;
|
|
59
59
|
}>;
|
package/dist/runner/bridge.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Reporter, TestRunResult } from './reporter.js';
|
|
|
3
3
|
export interface RunOptions {
|
|
4
4
|
baseDir: string;
|
|
5
5
|
appDataPath: string;
|
|
6
|
-
platform: 'web' | 'android' | 'ios' | 'common' | 'mobile';
|
|
6
|
+
platform: 'web' | 'android' | 'ios' | 'common' | 'mobile' | 'component';
|
|
7
7
|
suite?: string;
|
|
8
8
|
testCases?: Array<{
|
|
9
9
|
id: string;
|