repterm 0.1.0
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/api/describe.d.ts +18 -0
- package/dist/api/describe.d.ts.map +1 -0
- package/dist/api/describe.js +33 -0
- package/dist/api/describe.js.map +1 -0
- package/dist/api/expect.d.ts +43 -0
- package/dist/api/expect.d.ts.map +1 -0
- package/dist/api/expect.js +167 -0
- package/dist/api/expect.js.map +1 -0
- package/dist/api/hooks.d.ts +178 -0
- package/dist/api/hooks.d.ts.map +1 -0
- package/dist/api/hooks.js +231 -0
- package/dist/api/hooks.js.map +1 -0
- package/dist/api/steps.d.ts +45 -0
- package/dist/api/steps.d.ts.map +1 -0
- package/dist/api/steps.js +106 -0
- package/dist/api/steps.js.map +1 -0
- package/dist/api/test.d.ts +101 -0
- package/dist/api/test.d.ts.map +1 -0
- package/dist/api/test.js +207 -0
- package/dist/api/test.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +203 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/reporter.d.ts +108 -0
- package/dist/cli/reporter.d.ts.map +1 -0
- package/dist/cli/reporter.js +368 -0
- package/dist/cli/reporter.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/index.d.ts +47 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +86 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/withPlugins.d.ts +71 -0
- package/dist/plugin/withPlugins.d.ts.map +1 -0
- package/dist/plugin/withPlugins.js +101 -0
- package/dist/plugin/withPlugins.js.map +1 -0
- package/dist/recording/recorder.d.ts +45 -0
- package/dist/recording/recorder.d.ts.map +1 -0
- package/dist/recording/recorder.js +97 -0
- package/dist/recording/recorder.js.map +1 -0
- package/dist/runner/artifacts.d.ts +39 -0
- package/dist/runner/artifacts.d.ts.map +1 -0
- package/dist/runner/artifacts.js +59 -0
- package/dist/runner/artifacts.js.map +1 -0
- package/dist/runner/config.d.ts +46 -0
- package/dist/runner/config.d.ts.map +1 -0
- package/dist/runner/config.js +65 -0
- package/dist/runner/config.js.map +1 -0
- package/dist/runner/filter.d.ts +26 -0
- package/dist/runner/filter.d.ts.map +1 -0
- package/dist/runner/filter.js +88 -0
- package/dist/runner/filter.js.map +1 -0
- package/dist/runner/loader.d.ts +32 -0
- package/dist/runner/loader.d.ts.map +1 -0
- package/dist/runner/loader.js +252 -0
- package/dist/runner/loader.js.map +1 -0
- package/dist/runner/models.d.ts +261 -0
- package/dist/runner/models.d.ts.map +1 -0
- package/dist/runner/models.js +5 -0
- package/dist/runner/models.js.map +1 -0
- package/dist/runner/runner.d.ts +36 -0
- package/dist/runner/runner.d.ts.map +1 -0
- package/dist/runner/runner.js +216 -0
- package/dist/runner/runner.js.map +1 -0
- package/dist/runner/scheduler.d.ts +59 -0
- package/dist/runner/scheduler.d.ts.map +1 -0
- package/dist/runner/scheduler.js +157 -0
- package/dist/runner/scheduler.js.map +1 -0
- package/dist/runner/worker-runner.d.ts +6 -0
- package/dist/runner/worker-runner.d.ts.map +1 -0
- package/dist/runner/worker-runner.js +51 -0
- package/dist/runner/worker-runner.js.map +1 -0
- package/dist/runner/worker.d.ts +54 -0
- package/dist/runner/worker.d.ts.map +1 -0
- package/dist/runner/worker.js +112 -0
- package/dist/runner/worker.js.map +1 -0
- package/dist/terminal/session.d.ts +56 -0
- package/dist/terminal/session.d.ts.map +1 -0
- package/dist/terminal/session.js +126 -0
- package/dist/terminal/session.js.map +1 -0
- package/dist/terminal/terminal.d.ts +284 -0
- package/dist/terminal/terminal.d.ts.map +1 -0
- package/dist/terminal/terminal.js +1167 -0
- package/dist/terminal/terminal.js.map +1 -0
- package/dist/utils/dependencies.d.ts +19 -0
- package/dist/utils/dependencies.d.ts.map +1 -0
- package/dist/utils/dependencies.js +58 -0
- package/dist/utils/dependencies.js.map +1 -0
- package/dist/utils/timing.d.ts +55 -0
- package/dist/utils/timing.d.ts.map +1 -0
- package/dist/utils/timing.js +87 -0
- package/dist/utils/timing.js.map +1 -0
- package/package.json +43 -0
package/dist/api/test.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright-style test() registration and suite registry
|
|
3
|
+
*/
|
|
4
|
+
import { randomBytes } from 'crypto';
|
|
5
|
+
/**
|
|
6
|
+
* Global registry of test suites and cases
|
|
7
|
+
*/
|
|
8
|
+
class TestRegistry {
|
|
9
|
+
suites = new Map();
|
|
10
|
+
fileSuites = new Map();
|
|
11
|
+
suiteStack = []; // Stack for nested describe support
|
|
12
|
+
defaultSuite;
|
|
13
|
+
constructor() {
|
|
14
|
+
// Create a default suite for top-level tests
|
|
15
|
+
this.defaultSuite = {
|
|
16
|
+
id: 'default',
|
|
17
|
+
name: 'default',
|
|
18
|
+
tests: [],
|
|
19
|
+
suites: [],
|
|
20
|
+
config: {},
|
|
21
|
+
};
|
|
22
|
+
this.suites.set('default', this.defaultSuite);
|
|
23
|
+
this.suiteStack.push(this.defaultSuite);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the current suite (top of stack)
|
|
27
|
+
*/
|
|
28
|
+
getCurrentSuite() {
|
|
29
|
+
return this.suiteStack[this.suiteStack.length - 1] ?? this.defaultSuite;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the current suite ID (for hooks registration)
|
|
33
|
+
*/
|
|
34
|
+
getCurrentSuiteId() {
|
|
35
|
+
const suite = this.getCurrentSuite();
|
|
36
|
+
// Return undefined for default suite to indicate global hooks
|
|
37
|
+
return suite.id === 'default' ? undefined : suite.id;
|
|
38
|
+
}
|
|
39
|
+
/** Set by loader when loading a file so dynamically imported test code uses this suite (same registry instance). */
|
|
40
|
+
__pendingFileSuite;
|
|
41
|
+
/**
|
|
42
|
+
* Register a test case
|
|
43
|
+
*/
|
|
44
|
+
registerTest(name, fn, options) {
|
|
45
|
+
const suite = this.__pendingFileSuite ?? this.getCurrentSuite();
|
|
46
|
+
const testCase = {
|
|
47
|
+
id: this.generateId(),
|
|
48
|
+
name,
|
|
49
|
+
steps: [],
|
|
50
|
+
fn,
|
|
51
|
+
options,
|
|
52
|
+
};
|
|
53
|
+
suite.tests.push(testCase);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get all registered test suites
|
|
57
|
+
*/
|
|
58
|
+
getSuites() {
|
|
59
|
+
// Filter out empty default suite if there are file suites
|
|
60
|
+
const suites = Array.from(this.suites.values());
|
|
61
|
+
if (this.fileSuites.size > 0 && this.defaultSuite.tests.length === 0) {
|
|
62
|
+
return suites.filter(s => s.id !== 'default');
|
|
63
|
+
}
|
|
64
|
+
return suites;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get only root-level suites for execution
|
|
68
|
+
* This returns file-level suites if present, otherwise suites without parents
|
|
69
|
+
*/
|
|
70
|
+
getRootSuites() {
|
|
71
|
+
// If we have file suites, return only file-level suites
|
|
72
|
+
if (this.fileSuites.size > 0) {
|
|
73
|
+
return Array.from(this.fileSuites.values());
|
|
74
|
+
}
|
|
75
|
+
// No file suites - return default suite if it has content
|
|
76
|
+
if (this.defaultSuite.tests.length > 0 || (this.defaultSuite.suites && this.defaultSuite.suites.length > 0)) {
|
|
77
|
+
return [this.defaultSuite];
|
|
78
|
+
}
|
|
79
|
+
// Fallback: return suites without parents
|
|
80
|
+
return Array.from(this.suites.values()).filter(s => !s.parent);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get a specific suite by ID
|
|
84
|
+
*/
|
|
85
|
+
getSuite(id) {
|
|
86
|
+
return this.suites.get(id);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Push a new suite onto the stack (for describe() blocks)
|
|
90
|
+
*/
|
|
91
|
+
pushSuite(suite) {
|
|
92
|
+
const parentSuite = this.getCurrentSuite();
|
|
93
|
+
// Add to parent's nested suites
|
|
94
|
+
if (!parentSuite.suites) {
|
|
95
|
+
parentSuite.suites = [];
|
|
96
|
+
}
|
|
97
|
+
parentSuite.suites.push(suite);
|
|
98
|
+
// Link parent
|
|
99
|
+
suite.parent = parentSuite;
|
|
100
|
+
// Register in the global suites map
|
|
101
|
+
this.suites.set(suite.id, suite);
|
|
102
|
+
// Push onto stack
|
|
103
|
+
this.suiteStack.push(suite);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Pop the current suite from the stack (end of describe() block)
|
|
107
|
+
*/
|
|
108
|
+
popSuite() {
|
|
109
|
+
if (this.suiteStack.length > 1) {
|
|
110
|
+
this.suiteStack.pop();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Set the current suite (for describe() blocks) - legacy compatibility
|
|
115
|
+
*/
|
|
116
|
+
setCurrentSuite(suite) {
|
|
117
|
+
this.pushSuite(suite);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Set the current file and create/reuse a file-level suite.
|
|
121
|
+
* Uses full path as key so different files (e.g. same basename in different dirs) get separate suites.
|
|
122
|
+
* @returns the file suite (for loader to set pending global when loading dynamic files)
|
|
123
|
+
*/
|
|
124
|
+
setCurrentFile(filePath) {
|
|
125
|
+
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
126
|
+
const fileName = normalizedPath.split('/').pop() || filePath;
|
|
127
|
+
// Key by full path so each file gets its own suite (same basename in different dirs)
|
|
128
|
+
let fileSuite = this.fileSuites.get(normalizedPath);
|
|
129
|
+
if (!fileSuite) {
|
|
130
|
+
fileSuite = {
|
|
131
|
+
id: `file-${this.generateId()}`,
|
|
132
|
+
name: fileName,
|
|
133
|
+
tests: [],
|
|
134
|
+
suites: [],
|
|
135
|
+
config: {},
|
|
136
|
+
};
|
|
137
|
+
this.fileSuites.set(normalizedPath, fileSuite);
|
|
138
|
+
this.suites.set(fileSuite.id, fileSuite);
|
|
139
|
+
}
|
|
140
|
+
// Reset stack and push file suite
|
|
141
|
+
this.suiteStack = [fileSuite];
|
|
142
|
+
return fileSuite;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Reset to default suite
|
|
146
|
+
*/
|
|
147
|
+
resetCurrentSuite() {
|
|
148
|
+
this.popSuite();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Remove and return tests that were registered to the default suite.
|
|
152
|
+
* Used by the loader to reassign tests that landed on the default suite (e.g. due to
|
|
153
|
+
* async module evaluation) to the correct file-level suite.
|
|
154
|
+
*/
|
|
155
|
+
takeTestsFromDefaultSuite() {
|
|
156
|
+
const orphan = this.defaultSuite.tests;
|
|
157
|
+
this.defaultSuite.tests = [];
|
|
158
|
+
return orphan;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Clear all registered tests (for testing)
|
|
162
|
+
*/
|
|
163
|
+
clear() {
|
|
164
|
+
this.suites.clear();
|
|
165
|
+
this.fileSuites.clear();
|
|
166
|
+
this.defaultSuite = {
|
|
167
|
+
id: 'default',
|
|
168
|
+
name: 'default',
|
|
169
|
+
tests: [],
|
|
170
|
+
suites: [],
|
|
171
|
+
config: {},
|
|
172
|
+
};
|
|
173
|
+
this.suites.set('default', this.defaultSuite);
|
|
174
|
+
this.suiteStack = [this.defaultSuite];
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Generate a unique test ID
|
|
178
|
+
*/
|
|
179
|
+
generateId() {
|
|
180
|
+
return randomBytes(8).toString('hex');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** Global key so loader can pass the registry into dynamically imported test files (avoids duplicate module instances). */
|
|
184
|
+
const GLOBAL_REGISTRY_KEY = '__repterm_registry';
|
|
185
|
+
// Global registry instance; use shared one from loader when set (for dynamic import of test files)
|
|
186
|
+
const _globalRegistry = typeof globalThis !== 'undefined'
|
|
187
|
+
? globalThis[GLOBAL_REGISTRY_KEY]
|
|
188
|
+
: undefined;
|
|
189
|
+
export const registry = _globalRegistry ?? new TestRegistry();
|
|
190
|
+
export function test(name, optionsOrFn, maybeFn) {
|
|
191
|
+
const options = typeof optionsOrFn === 'function' ? undefined : optionsOrFn;
|
|
192
|
+
const fn = typeof optionsOrFn === 'function' ? optionsOrFn : maybeFn;
|
|
193
|
+
registry.registerTest(name, fn, options);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get all registered tests
|
|
197
|
+
*/
|
|
198
|
+
export function getTests() {
|
|
199
|
+
return registry.getSuites();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Clear all registered tests
|
|
203
|
+
*/
|
|
204
|
+
export function clearTests() {
|
|
205
|
+
registry.clear();
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/api/test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,YAAY;IACR,MAAM,GAA2B,IAAI,GAAG,EAAE,CAAC;IAC3C,UAAU,GAA2B,IAAI,GAAG,EAAE,CAAC;IAC/C,UAAU,GAAgB,EAAE,CAAC,CAAC,oCAAoC;IAClE,YAAY,CAAY;IAEhC;QACE,6CAA6C;QAC7C,IAAI,CAAC,YAAY,GAAG;YAClB,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;SACX,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACK,eAAe;QACrB,OAA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UAAU,QAAQ;IACtB,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* CLI entrypoint and command parsing
|
|
4
|
+
* Handles command-line arguments and orchestrates test execution
|
|
5
|
+
*/
|
|
6
|
+
import { parseArgs } from 'util';
|
|
7
|
+
import { loadConfig, getDefaultConfig } from '../runner/config.js';
|
|
8
|
+
import { createArtifactManager } from '../runner/artifacts.js';
|
|
9
|
+
import { discoverTests, loadTestFiles } from '../runner/loader.js';
|
|
10
|
+
import { runAllSuites } from '../runner/runner.js';
|
|
11
|
+
import { createScheduler } from '../runner/scheduler.js';
|
|
12
|
+
import { createReporter } from './reporter.js';
|
|
13
|
+
import { checkDependencies, printDependencyCheck } from '../utils/dependencies.js';
|
|
14
|
+
/**
|
|
15
|
+
* Main CLI entry point
|
|
16
|
+
*/
|
|
17
|
+
async function main() {
|
|
18
|
+
try {
|
|
19
|
+
const args = parseArgs({
|
|
20
|
+
args: process.argv.slice(2),
|
|
21
|
+
options: {
|
|
22
|
+
record: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
short: 'r',
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
workers: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
short: 'w',
|
|
30
|
+
},
|
|
31
|
+
timeout: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
short: 't',
|
|
34
|
+
},
|
|
35
|
+
verbose: {
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
short: 'v',
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
help: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
short: 'h',
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
'slow-threshold': {
|
|
46
|
+
type: 'string', // parseArgs doesn't support number type directly for values
|
|
47
|
+
},
|
|
48
|
+
'recording-dir': {
|
|
49
|
+
type: 'string',
|
|
50
|
+
},
|
|
51
|
+
'prompt-lines': {
|
|
52
|
+
type: 'string',
|
|
53
|
+
short: 'p',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
allowPositionals: true,
|
|
57
|
+
});
|
|
58
|
+
// Show help
|
|
59
|
+
if (args.values.help) {
|
|
60
|
+
showHelp();
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
// Get test paths
|
|
64
|
+
const testPaths = args.positionals;
|
|
65
|
+
if (testPaths.length === 0) {
|
|
66
|
+
console.error('Error: No test paths provided');
|
|
67
|
+
showHelp();
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
// Load configuration - use default config values, only override if user specified
|
|
71
|
+
const defaultConfig = getDefaultConfig();
|
|
72
|
+
const config = loadConfig({
|
|
73
|
+
record: {
|
|
74
|
+
enabled: args.values.record,
|
|
75
|
+
},
|
|
76
|
+
parallel: {
|
|
77
|
+
workers: args.values.workers ? parseInt(args.values.workers, 10) : 1,
|
|
78
|
+
},
|
|
79
|
+
timeouts: args.values.timeout ? {
|
|
80
|
+
testMs: parseInt(args.values.timeout, 10),
|
|
81
|
+
suiteMs: defaultConfig.timeouts.suiteMs,
|
|
82
|
+
} : undefined, // undefined = use DEFAULT_CONFIG
|
|
83
|
+
terminal: {
|
|
84
|
+
promptLineCount: args.values['prompt-lines'] ? parseInt(args.values['prompt-lines'], 10) : undefined,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
// Create artifact manager
|
|
88
|
+
const artifactManager = createArtifactManager(args.values['recording-dir']);
|
|
89
|
+
// Discover test files
|
|
90
|
+
const testFiles = await discoverTests(testPaths);
|
|
91
|
+
if (testFiles.length === 0) {
|
|
92
|
+
console.error('Error: No test files found');
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
// Initialize artifact manager
|
|
96
|
+
artifactManager.init();
|
|
97
|
+
// Check dependencies if recording is enabled
|
|
98
|
+
if (config.record.enabled) {
|
|
99
|
+
console.log('Checking dependencies for recording mode...');
|
|
100
|
+
const depCheck = await checkDependencies(true);
|
|
101
|
+
printDependencyCheck(depCheck);
|
|
102
|
+
if (!depCheck.allPresent) {
|
|
103
|
+
console.error('\nRecording mode requires asciinema and tmux to be installed.');
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Show discovery info
|
|
108
|
+
console.log(`Found ${testFiles.length} test file(s)`);
|
|
109
|
+
// Load test files
|
|
110
|
+
console.log('Loading tests...');
|
|
111
|
+
await loadTestFiles(testFiles);
|
|
112
|
+
// Get registered tests from the registry
|
|
113
|
+
// Use relative import to ensure we use the same registry instance
|
|
114
|
+
const { registry } = await import('../api/test.js');
|
|
115
|
+
const allSuites = registry.getRootSuites();
|
|
116
|
+
// Apply test filtering based on --record flag
|
|
117
|
+
const { filterSuites, countTests } = await import('../runner/filter.js');
|
|
118
|
+
const suites = filterSuites(allSuites, config.record.enabled);
|
|
119
|
+
const totalTests = countTests(suites);
|
|
120
|
+
if (totalTests === 0) {
|
|
121
|
+
if (config.record.enabled) {
|
|
122
|
+
console.error('No tests marked with { record: true } found.');
|
|
123
|
+
console.error('Use describe/test with { record: true } to mark recording tests.');
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.error('No tests found.');
|
|
127
|
+
}
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
const modeLabel = config.record.enabled ? ' (recording mode)' : '';
|
|
131
|
+
console.log(`Running ${totalTests} test(s)${modeLabel}...`);
|
|
132
|
+
console.log('');
|
|
133
|
+
// Create reporter for streaming output
|
|
134
|
+
const reporter = createReporter({
|
|
135
|
+
verbose: args.values.verbose,
|
|
136
|
+
slowThreshold: args.values['slow-threshold']
|
|
137
|
+
? parseInt(args.values['slow-threshold'], 10)
|
|
138
|
+
: undefined,
|
|
139
|
+
});
|
|
140
|
+
// Run tests (parallel or sequential based on worker count)
|
|
141
|
+
let results;
|
|
142
|
+
const onTestStart = (testInfo) => reporter.onTestStart(testInfo);
|
|
143
|
+
const onResult = (result) => reporter.onTestResult(result);
|
|
144
|
+
if (config.parallel.workers > 1) {
|
|
145
|
+
// Use scheduler for parallel execution
|
|
146
|
+
const scheduler = createScheduler({
|
|
147
|
+
config,
|
|
148
|
+
artifactBaseDir: artifactManager.getBaseDir(),
|
|
149
|
+
onResult,
|
|
150
|
+
});
|
|
151
|
+
results = await scheduler.run(suites);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// Single worker - run sequentially
|
|
155
|
+
results = await runAllSuites(suites, { config, artifactManager, onResult, onTestStart });
|
|
156
|
+
}
|
|
157
|
+
// Report final summary
|
|
158
|
+
reporter.onRunComplete(results);
|
|
159
|
+
// Exit with appropriate code
|
|
160
|
+
const failed = results.filter((r) => r.status === 'fail').length;
|
|
161
|
+
process.exit(failed > 0 ? 1 : 0);
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
console.error('Fatal error:', error.message);
|
|
165
|
+
if (error.stack) {
|
|
166
|
+
console.error(error.stack);
|
|
167
|
+
}
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Show help text
|
|
173
|
+
*/
|
|
174
|
+
function showHelp() {
|
|
175
|
+
console.log(`
|
|
176
|
+
Repterm - CLI/TUI Test Framework
|
|
177
|
+
|
|
178
|
+
Usage:
|
|
179
|
+
repterm [options] <test-paths...>
|
|
180
|
+
|
|
181
|
+
Options:
|
|
182
|
+
-r, --record Run recording tests (tests marked with { record: true })
|
|
183
|
+
-w, --workers <n> Number of parallel workers (default: 1)
|
|
184
|
+
-t, --timeout <ms> Test timeout in milliseconds (default: from config)
|
|
185
|
+
-v, --verbose Verbose output with stack traces
|
|
186
|
+
-p, --prompt-lines <n> 提示符占用的行数(用于输出捕获,0=自动检测)
|
|
187
|
+
--slow-threshold <ms> Show duration for tests slower than this (default: 50)
|
|
188
|
+
--recording-dir <path> Directory for recording artifacts (default: /tmp/repterm)
|
|
189
|
+
-h, --help Show this help message
|
|
190
|
+
|
|
191
|
+
Test Modes:
|
|
192
|
+
Without --record: Runs tests NOT marked with { record: true }
|
|
193
|
+
With --record: Runs ONLY tests marked with { record: true }
|
|
194
|
+
|
|
195
|
+
Examples:
|
|
196
|
+
repterm tests/ # Run non-recording tests
|
|
197
|
+
repterm --record tests/ # Run recording tests only
|
|
198
|
+
repterm --workers 4 tests/
|
|
199
|
+
`);
|
|
200
|
+
}
|
|
201
|
+
// Run CLI
|
|
202
|
+
main();
|
|
203
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGnF;;GAEG;AACH,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,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AC3F,CAAC;QAED,uBAAuB;QACvB,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAEhC,6BAA6B;QAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,cAAc,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;QACxD,IAAK,KAAe,CAAC,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAE,KAAe,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;GAwBX,CAAC,CAAC;AACL,CAAC;AAED,UAAU;AACV,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reporter with failure diagnostics
|
|
3
|
+
* Formats and displays test results in Vitest-style output
|
|
4
|
+
*/
|
|
5
|
+
import type { RunResult } from '../runner/models.js';
|
|
6
|
+
export interface ReporterOptions {
|
|
7
|
+
verbose?: boolean;
|
|
8
|
+
colors?: boolean;
|
|
9
|
+
/** Show duration for tests slower than this threshold (ms), default: 50 */
|
|
10
|
+
slowThreshold?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reporter for test results with Vitest-style formatting
|
|
14
|
+
*/
|
|
15
|
+
export declare class Reporter {
|
|
16
|
+
private options;
|
|
17
|
+
private slowThreshold;
|
|
18
|
+
constructor(options?: ReporterOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Track last suite path for header printing
|
|
21
|
+
*/
|
|
22
|
+
private lastSuitePath;
|
|
23
|
+
/**
|
|
24
|
+
* Called when a test is about to start (before hooks run)
|
|
25
|
+
* Prints suite headers early to ensure proper output ordering
|
|
26
|
+
*/
|
|
27
|
+
onTestStart(testInfo: {
|
|
28
|
+
suitePath: string[];
|
|
29
|
+
testName: string;
|
|
30
|
+
}): void;
|
|
31
|
+
/**
|
|
32
|
+
* Report a single test result immediately
|
|
33
|
+
*/
|
|
34
|
+
onTestResult(result: RunResult): void;
|
|
35
|
+
/**
|
|
36
|
+
* Report final summary and failures
|
|
37
|
+
*/
|
|
38
|
+
onRunComplete(results: RunResult[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Report all test results at once (Legacy/Batch mode)
|
|
41
|
+
*/
|
|
42
|
+
report(results: RunResult[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Build a tree of suites and tests
|
|
45
|
+
*/
|
|
46
|
+
private buildSuiteTree;
|
|
47
|
+
/**
|
|
48
|
+
* Print a suite node and its children recursively
|
|
49
|
+
*/
|
|
50
|
+
private printSuiteNode;
|
|
51
|
+
/**
|
|
52
|
+
* Helper to count total tests in a node
|
|
53
|
+
*/
|
|
54
|
+
private countTests;
|
|
55
|
+
/**
|
|
56
|
+
* Print a single test result
|
|
57
|
+
*/
|
|
58
|
+
private printTestResult;
|
|
59
|
+
/**
|
|
60
|
+
* Print test summary in Vitest style
|
|
61
|
+
*/
|
|
62
|
+
private printSummary;
|
|
63
|
+
/**
|
|
64
|
+
* Print failure details
|
|
65
|
+
*/
|
|
66
|
+
private printFailures;
|
|
67
|
+
/**
|
|
68
|
+
* Format suite summary line
|
|
69
|
+
*/
|
|
70
|
+
private formatSuiteSummary;
|
|
71
|
+
/**
|
|
72
|
+
* Format test summary line
|
|
73
|
+
*/
|
|
74
|
+
private formatTestSummary;
|
|
75
|
+
/**
|
|
76
|
+
* Get status symbol
|
|
77
|
+
*/
|
|
78
|
+
private getStatusSymbol;
|
|
79
|
+
/**
|
|
80
|
+
* Get status color
|
|
81
|
+
*/
|
|
82
|
+
private getStatusColor;
|
|
83
|
+
/**
|
|
84
|
+
* Format duration (short)
|
|
85
|
+
*/
|
|
86
|
+
private formatDuration;
|
|
87
|
+
/**
|
|
88
|
+
* Format duration (long, for summary)
|
|
89
|
+
*/
|
|
90
|
+
private formatDurationLong;
|
|
91
|
+
/**
|
|
92
|
+
* Format value for diff display
|
|
93
|
+
*/
|
|
94
|
+
private formatValue;
|
|
95
|
+
/**
|
|
96
|
+
* Indent multi-line text blocks for verbose diagnostics
|
|
97
|
+
*/
|
|
98
|
+
private formatIndentedBlock;
|
|
99
|
+
/**
|
|
100
|
+
* Apply color to text
|
|
101
|
+
*/
|
|
102
|
+
private color;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a reporter
|
|
106
|
+
*/
|
|
107
|
+
export declare function createReporter(options?: ReporterOptions): Reporter;
|
|
108
|
+
//# sourceMappingURL=reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../src/cli/reporter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAUD;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,GAAE,eAAoB;IAQzC;;OAEG;IACH,OAAO,CAAC,aAAa,CAAgB;IAErC;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE;QAAE,SAAS,EAAE,MA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