Skip to content

Commit 99f8de3

Browse files
committed
Simplify test logger
1 parent 26fdc85 commit 99f8de3

1 file changed

Lines changed: 16 additions & 33 deletions

File tree

src/test/utils/testLogger.ts

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,89 +7,72 @@
77

88
/**
99
* Test logger that provides structured output for test execution.
10-
* Uses synchronous writes to prevent interleaving.
10+
* Works with Mocha's test output - logs go to stdout, errors to stderr.
1111
*/
1212
class TestLogger {
1313
/**
14-
* Log a message to stdout using synchronous write
14+
* Log a message to stdout
1515
*/
1616
log(message: string): void {
17-
process.stdout.write(message + '\n');
17+
console.log(message);
1818
}
1919

2020
/**
21-
* Log an error message to stderr with clear separation
22-
* Uses a single synchronous write to prevent interleaving
21+
* Log an error message - just log it, let Mocha handle the error display
2322
*/
2423
error(message: string, error?: any): void {
25-
// Build the entire error message as a single string
26-
let errorOutput = '\n' + '='.repeat(80) + '\n';
27-
errorOutput += `[ERROR] ${message}\n`;
28-
29-
if (error) {
30-
if (error.stack) {
31-
errorOutput += error.stack + '\n';
32-
} else {
33-
errorOutput += String(error) + '\n';
34-
}
35-
}
36-
37-
errorOutput += '='.repeat(80) + '\n\n';
38-
39-
// Write the entire error message in one synchronous operation
40-
process.stderr.write(errorOutput);
24+
// Just log the error message - Mocha will display the full error
25+
console.error(`[ERROR] ${message}`);
4126
}
4227

4328
/**
4429
* Log an info message with special formatting
4530
*/
4631
info(message: string): void {
47-
this.log(`[INFO] ${message}`);
32+
console.log(`[INFO] ${message}`);
4833
}
4934

5035
/**
51-
* Log a test start message
36+
* Log a test start message - minimal output since Mocha shows test names
5237
*/
5338
testStart(testName: string): void {
54-
this.log(`\n${'='.repeat(80)}`);
55-
this.log(`[TEST START] ${testName}`);
56-
this.log('='.repeat(80));
39+
console.log(`[TEST START] ${testName}`);
5740
}
5841

5942
/**
6043
* Log a test completion message
6144
*/
6245
testComplete(testName: string): void {
63-
this.log(`[TEST COMPLETE] ${testName} passed`);
64-
this.log('='.repeat(80) + '\n');
46+
console.log(`[TEST COMPLETE] ${testName}`);
6547
}
6648

6749
/**
68-
* Log a test failure message
50+
* Log a test failure message - let Mocha handle the error display
6951
*/
7052
testFailed(testName: string, error: any): void {
71-
this.error(`Test failed: ${testName}`, error);
53+
// Don't log here - just throw the error so Mocha can display it properly
54+
throw error;
7255
}
7356

7457
/**
7558
* Log a step in the test
7659
*/
7760
step(stepNumber: number, description: string): void {
78-
this.log(`[STEP ${stepNumber}] ${description}`);
61+
console.log(` [STEP ${stepNumber}] ${description}`);
7962
}
8063

8164
/**
8265
* Log a successful step completion
8366
*/
8467
stepSuccess(stepNumber: number, description: string): void {
85-
this.log(`[STEP ${stepNumber} - SUCCESS] ${description}`);
68+
console.log(` [STEP ${stepNumber} ] ${description}`);
8669
}
8770

8871
/**
8972
* Log a skip message
9073
*/
9174
skip(message: string): void {
92-
this.log(`[SKIP] ${message}`);
75+
console.log(`[SKIP] ${message}`);
9376
}
9477
}
9578

0 commit comments

Comments
 (0)