@testspectra/cli 1.2.10 → 1.2.12
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/dist/commands/test.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export interface TestCommandOptions {
|
|
|
5
5
|
stepDelay?: string | number;
|
|
6
6
|
delay?: string | number;
|
|
7
7
|
spec?: string;
|
|
8
|
+
failed?: boolean | string;
|
|
8
9
|
output?: string;
|
|
9
10
|
concurrency?: string | number;
|
|
10
11
|
}
|
|
@@ -20,6 +21,13 @@ export interface TestCommandOptions {
|
|
|
20
21
|
* scaffolding up front (same output as `spectra sync-types`) keeps the reference resolvable.
|
|
21
22
|
*/
|
|
22
23
|
export declare function ensureTestSpectraScaffolding(cwd: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Reads the previous component-test report and returns the titles of failed tests.
|
|
26
|
+
* Mirrors `spectra run --failed` (see commands/run.ts): the Rust runner performs the actual
|
|
27
|
+
* filtering by title, this only backs the "nothing failed" early exit and the log line.
|
|
28
|
+
* Returns `[]` when the report is missing or unparseable — never throws.
|
|
29
|
+
*/
|
|
30
|
+
export declare function collectFailedTestTitles(reportPath: string): string[];
|
|
23
31
|
/**
|
|
24
32
|
* `spectra test` — runs React component tests via the native CDP engine
|
|
25
33
|
* (`@testspectra/react` bundle server + Rust `core/orchestrator::component_runner`).
|
package/dist/commands/test.js
CHANGED
|
@@ -45,6 +45,23 @@ async function resolveBrowserExecutable(cwd) {
|
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Reads the previous component-test report and returns the titles of failed tests.
|
|
50
|
+
* Mirrors `spectra run --failed` (see commands/run.ts): the Rust runner performs the actual
|
|
51
|
+
* filtering by title, this only backs the "nothing failed" early exit and the log line.
|
|
52
|
+
* Returns `[]` when the report is missing or unparseable — never throws.
|
|
53
|
+
*/
|
|
54
|
+
export function collectFailedTestTitles(reportPath) {
|
|
55
|
+
try {
|
|
56
|
+
const prev = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
|
|
57
|
+
return (prev.suites || []).flatMap((s) => (s.tests || [])
|
|
58
|
+
.filter((t) => t.passed === false || t.status === 'failed')
|
|
59
|
+
.map((t) => String(t.title ?? '')));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
48
65
|
/**
|
|
49
66
|
* `spectra test` — runs React component tests via the native CDP engine
|
|
50
67
|
* (`@testspectra/react` bundle server + Rust `core/orchestrator::component_runner`).
|
|
@@ -113,6 +130,23 @@ export async function testCommand(options = {}) {
|
|
|
113
130
|
}
|
|
114
131
|
const concurrency = options.concurrency !== undefined ? parseInt(String(options.concurrency), 10) : undefined;
|
|
115
132
|
const outputFile = options.output ? path.resolve(cwd, options.output) : undefined;
|
|
133
|
+
// Same previous-report contract as `spectra run --failed`: the Rust runner resolves the
|
|
134
|
+
// default report at <cwd>/.testspectra/reports/result.json when no explicit output is given.
|
|
135
|
+
const reportPath = outputFile ?? path.join(cwd, '.testspectra', 'reports', 'result.json');
|
|
136
|
+
const isFailedMode = options.failed !== undefined;
|
|
137
|
+
let failedTarget;
|
|
138
|
+
if (typeof options.failed === 'string' && options.failed !== 'true') {
|
|
139
|
+
failedTarget = options.failed;
|
|
140
|
+
}
|
|
141
|
+
if (isFailedMode) {
|
|
142
|
+
const failedTitles = collectFailedTestTitles(reportPath);
|
|
143
|
+
if (failedTitles.length === 0) {
|
|
144
|
+
p.log.success('✨ [TestSpectra] No failed tests found in previous test session! Everything is already passing.');
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const targetDesc = failedTarget ? `target '${failedTarget}' in ` : '';
|
|
148
|
+
p.log.info(`🔄 [TestSpectra] Re-running ${targetDesc}${failedTitles.length} failed test(s) with session state carry-over...`);
|
|
149
|
+
}
|
|
116
150
|
// Reuses the exact same semantic terminal reporter `spectra run` drives (see
|
|
117
151
|
// docs/v2/cli/matchers-semantic-reporter.md) — @testspectra/react emits the identical
|
|
118
152
|
// [TESTSPECTRA_*] protocol lines the E2E Rust orchestrator does (see tools/react/src/prelude.ts
|
|
@@ -144,6 +178,8 @@ export async function testCommand(options = {}) {
|
|
|
144
178
|
},
|
|
145
179
|
specs: options.spec ? [options.spec] : undefined,
|
|
146
180
|
concurrency: concurrency !== undefined && !isNaN(concurrency) ? concurrency : undefined,
|
|
181
|
+
failedOnly: isFailedMode,
|
|
182
|
+
failedTarget,
|
|
147
183
|
outputJsonPath: outputFile,
|
|
148
184
|
}, reporter);
|
|
149
185
|
ok = runResult.status.toLowerCase() === 'passed';
|
package/dist/index.js
CHANGED
|
@@ -202,6 +202,7 @@ Examples:
|
|
|
202
202
|
.description('Run React component tests via the native CDP engine')
|
|
203
203
|
.option('-w, --cwd <dir>', 'Custom workspace directory')
|
|
204
204
|
.option('-s, --spec <path>', 'Spec file path (or substring filter) to execute')
|
|
205
|
+
.option('--failed [targets]', 'Re-run failed tests from previous run (accepts comma-separated test IDs or spec paths)')
|
|
205
206
|
.option('--headless', 'Run in headless mode (default)')
|
|
206
207
|
.option('--no-headless', 'Run in headed mode')
|
|
207
208
|
.option('--headed', 'Run the browser in visible GUI mode (alias for --no-headless)')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testspectra/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "TestSpectra Cross-Platform Test Runner CLI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@clack/prompts": "^1.7.0",
|
|
28
|
-
"@testspectra/matchers": "^1.2.
|
|
29
|
-
"@testspectra/react": "^1.2.
|
|
30
|
-
"@testspectra/reporter": "^1.2.
|
|
31
|
-
"@testspectra/skills": "^1.2.
|
|
28
|
+
"@testspectra/matchers": "^1.2.12",
|
|
29
|
+
"@testspectra/react": "^1.2.12",
|
|
30
|
+
"@testspectra/reporter": "^1.2.12",
|
|
31
|
+
"@testspectra/skills": "^1.2.12",
|
|
32
32
|
"chalk": "^5.3.0",
|
|
33
33
|
"commander": "^12.1.0",
|
|
34
34
|
"cross-spawn": "^7.0.6",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"zod": "^3.23.8"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@testspectra/cli-darwin-arm64": "1.2.
|
|
43
|
-
"@testspectra/cli-linux-x64": "1.2.
|
|
44
|
-
"@testspectra/cli-win32-x64": "1.2.
|
|
42
|
+
"@testspectra/cli-darwin-arm64": "1.2.12",
|
|
43
|
+
"@testspectra/cli-linux-x64": "1.2.12",
|
|
44
|
+
"@testspectra/cli-win32-x64": "1.2.12"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/cross-spawn": "^6.0.6",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"postinstall": "spectra sync-types"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@testspectra/cli": "^1.2.
|
|
21
|
-
"@testspectra/matchers": "^1.2.
|
|
22
|
-
"@testspectra/plugin-demo": "^1.2.
|
|
20
|
+
"@testspectra/cli": "^1.2.12",
|
|
21
|
+
"@testspectra/matchers": "^1.2.12",
|
|
22
|
+
"@testspectra/plugin-demo": "^1.2.12",
|
|
23
23
|
"@types/node": "^20.14.0",
|
|
24
24
|
"@wdio/cli": "^9.2.8",
|
|
25
25
|
"@wdio/local-runner": "^9.2.8",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"postinstall": "spectra sync-types"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@testspectra/cli": "^1.2.
|
|
16
|
-
"@testspectra/matchers": "^1.2.
|
|
15
|
+
"@testspectra/cli": "^1.2.12",
|
|
16
|
+
"@testspectra/matchers": "^1.2.12",
|
|
17
17
|
"@types/node": "^20.14.0",
|
|
18
18
|
"@wdio/cli": "^9.2.8",
|
|
19
19
|
"@wdio/local-runner": "^9.2.8",
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"nx": "^20.8.4",
|
|
25
25
|
"typescript": "^5.4.5",
|
|
26
26
|
"webdriverio": "^9.2.8",
|
|
27
|
-
"@testspectra/plugin-demo": "^1.2.
|
|
27
|
+
"@testspectra/plugin-demo": "^1.2.12"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"postinstall": "spectra sync-types"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@testspectra/cli": "^1.2.
|
|
18
|
-
"@testspectra/matchers": "^1.2.
|
|
19
|
-
"@testspectra/react": "^1.2.
|
|
17
|
+
"@testspectra/cli": "^1.2.12",
|
|
18
|
+
"@testspectra/matchers": "^1.2.12",
|
|
19
|
+
"@testspectra/react": "^1.2.12",
|
|
20
20
|
"@types/node": "^20.14.0",
|
|
21
21
|
"@types/react": "^18.3.3",
|
|
22
22
|
"@types/react-dom": "^18.3.0",
|