Skip to content

Commit 8f03853

Browse files
committed
test: suppress console logs to clean up test output
- Create E2E setup file to filter error and debug logs - Update unit test setup to filter error logs - Prevent console log spam from obscuring test summary
1 parent 69bb1ed commit 8f03853

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

vitest.e2e.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export default defineConfig({
2424
// "src/**/*.test.ts",
2525
],
2626

27+
// Setup file for E2E tests
28+
setupFiles: ["./vitest.e2e.setup.ts"],
29+
2730
// Browser testing configuration
2831
browser: {
2932
enabled: true,

vitest.e2e.setup.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Setup file for E2E tests
3+
* Suppresses expected error and debug logs during testing
4+
*/
5+
6+
// Suppress expected error logs from error isolation tests
7+
// These tests intentionally throw errors to verify error handling
8+
const originalError = console.error;
9+
10+
console.error = (...args: unknown[]) => {
11+
// Filter out expected error logs from error isolation pattern
12+
const message = args[0];
13+
if (
14+
typeof message === "string" &&
15+
(message === "[__web_sqlite] Event callback error:" ||
16+
message === "[LogDispatcher] Callback error:")
17+
) {
18+
// Suppress these expected error logs during tests
19+
return;
20+
}
21+
// Pass through other errors
22+
originalError(...args);
23+
};
24+
25+
// Suppress debug logs during E2E tests
26+
// These are for development troubleshooting but clutter test output
27+
const _originalDebug = console.debug;
28+
29+
console.debug = (..._args: unknown[]) => {
30+
// Suppress all console.debug output during tests
31+
// Uncomment to enable debug logs when troubleshooting:
32+
// _originalDebug(..._args);
33+
};

vitest.unit.setup.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,22 @@
88
if (typeof global.window === "undefined") {
99
global.window = {} as unknown as Window & typeof globalThis;
1010
}
11+
12+
// Suppress expected error logs from error isolation tests
13+
// These tests intentionally throw errors to verify error handling
14+
const originalError = console.error;
15+
16+
console.error = (...args: unknown[]) => {
17+
// Filter out expected error logs from error isolation pattern
18+
const message = args[0];
19+
if (
20+
typeof message === "string" &&
21+
(message === "[__web_sqlite] Event callback error:" ||
22+
message === "[LogDispatcher] Callback error:")
23+
) {
24+
// Suppress these expected error logs during tests
25+
return;
26+
}
27+
// Pass through other errors
28+
originalError(...args);
29+
};

0 commit comments

Comments
 (0)