-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathjest.setup.js
More file actions
38 lines (32 loc) · 1.14 KB
/
jest.setup.js
File metadata and controls
38 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Jest setup configuration to reduce log noise during tests
*/
// Set environment variables to minimize logging during tests
process.env.LOG_LEVEL = 'error';
process.env.QUIET_MODE = 'true';
process.env.NODE_ENV = 'test';
// Override console methods to reduce noise (but preserve error logs)
const originalConsoleLog = console.log;
const originalConsoleWarn = console.warn;
// Only suppress non-error console output during tests
console.log = (...args) => {
// Allow logs that seem to be from test assertions or failures
const message = args.join(' ');
if (
message.includes('FAIL') ||
message.includes('PASS') ||
message.includes('✓') ||
message.includes('✗')
) {
originalConsoleLog(...args);
}
// Suppress other logs unless in debug mode
};
console.info = () => {}; // Suppress info logs
console.debug = () => {}; // Suppress debug logs
// Keep warnings and errors visible (no change needed for console.error)
console.warn = originalConsoleWarn;
// Restore console methods after each test to avoid interfering with test output
afterEach(() => {
// Keep the suppression active - only restore if explicitly needed
});