feat(tstest): add support for package.json before scripts during test execution

This commit is contained in:
2026-03-19 15:38:02 +00:00
parent bc39793682
commit cf4e5c33e8
5 changed files with 197 additions and 2 deletions

View File

@@ -122,6 +122,40 @@ export class TsTestLogger {
this.log(this.format(`[${'█'.repeat(filled)}${'░'.repeat(empty)}] ${message}`, 'dim'));
}
// Before-script lifecycle hooks
beforeScriptStart(label: string, command: string) {
if (this.options.json) {
this.logJson({ event: 'beforeScript', label, command });
return;
}
if (this.options.quiet) {
this.log(`Running ${label}...`);
} else {
this.log(this.format(`\n🔧 Running ${label}...`, 'cyan'));
this.log(this.format(` Command: ${command}`, 'dim'));
}
}
beforeScriptEnd(label: string, success: boolean, durationMs: number) {
const durationStr = durationMs >= 1000 ? `${(durationMs / 1000).toFixed(1)}s` : `${durationMs}ms`;
if (this.options.json) {
this.logJson({ event: 'beforeScriptEnd', label, success, durationMs });
return;
}
if (this.options.quiet) {
this.log(success ? `${label} done (${durationStr})` : `${label} FAILED`);
} else {
if (success) {
this.log(this.format(`${label} completed (${durationStr})`, 'green'));
} else {
this.log(this.format(`${label} failed (${durationStr})`, 'red'));
}
}
}
// Test discovery
testDiscovery(count: number, pattern: string, executionMode: string) {
if (this.options.json) {