You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test('properly logs trace messages to the console.',()=>{
13
24
constspy=vi.spyOn(console,'log')
14
25
15
26
constlogger=newLogger()
16
27
17
28
logger.trace('Entering processOrder function with orderId=12345.')
18
29
19
-
constexpectedMessage=`[${chalk.hex(Colors.LightGray)('TRACE')}] ${chalk.hex(Colors.LightGray)('2024-09-30T22:00:00.000Z')} Entering processOrder function with orderId=12345.`
30
+
constexpectedMessage=`[TRACE] 2024-09-30T22:00:00.000Z Entering processOrder function with orderId=12345.`
20
31
21
32
expect(spy).toHaveBeenCalledWith(expectedMessage)
22
33
})
@@ -28,7 +39,7 @@ describe('Logger', () => {
28
39
29
40
logger.debug('Processing order with orderId=12345.')
30
41
31
-
constexpectedMessage=`[${chalk.hex(Colors.LightGray)('DEBUG')}] ${chalk.hex(Colors.LightGray)('2024-09-30T22:00:00.000Z')} Processing order with orderId=12345.`
42
+
constexpectedMessage=`[DEBUG] 2024-09-30T22:00:00.000Z Processing order with orderId=12345.`
32
43
33
44
expect(spy).toHaveBeenCalledWith(expectedMessage)
34
45
})
@@ -40,7 +51,7 @@ describe('Logger', () => {
40
51
41
52
logger.info('Order processed successfully.')
42
53
43
-
constexpectedMessage=`[${chalk.hex(Colors.LightGray)('INFO')}] ${chalk.hex(Colors.LightGray)('2024-09-30T22:00:00.000Z')} Order processed successfully.`
54
+
constexpectedMessage=`[INFO] 2024-09-30T22:00:00.000Z Order processed successfully.`
44
55
45
56
expect(spy).toHaveBeenCalledWith(expectedMessage)
46
57
})
@@ -52,7 +63,7 @@ describe('Logger', () => {
52
63
53
64
logger.warn('Order with orderId=12345 is missing a delivery address.')
54
65
55
-
constexpectedMessage=`[${chalk.hex(Colors.LightGray)('WARN')}] ${chalk.hex(Colors.LightGray)('2024-09-30T22:00:00.000Z')} Order with orderId=12345 is missing a delivery address.`
66
+
constexpectedMessage=`[WARN] 2024-09-30T22:00:00.000Z Order with orderId=12345 is missing a delivery address.`
56
67
57
68
expect(spy).toHaveBeenCalledWith(expectedMessage)
58
69
})
@@ -64,7 +75,7 @@ describe('Logger', () => {
64
75
65
76
logger.error('Failed to process order with orderId=12345.')
66
77
67
-
constexpectedMessage=`[${chalk.hex(Colors.LightGray)('ERROR')}] ${chalk.hex(Colors.LightGray)('2024-09-30T22:00:00.000Z')} Failed to process order with orderId=12345.`
78
+
constexpectedMessage=`[ERROR] 2024-09-30T22:00:00.000Z Failed to process order with orderId=12345.`
68
79
69
80
expect(spy).toHaveBeenCalledWith(expectedMessage)
70
81
})
@@ -76,7 +87,7 @@ describe('Logger', () => {
76
87
77
88
logger.fatal('Failed to start the application.')
78
89
79
-
constexpectedMessage=`[${chalk.hex(Colors.LightGray)('FATAL')}] ${chalk.hex(Colors.LightGray)('2024-09-30T22:00:00.000Z')} Failed to start the application.`
90
+
constexpectedMessage=`[FATAL] 2024-09-30T22:00:00.000Z Failed to start the application.`
constexpectedMessage=`[${chalk.hex(Colors.LightGray)('INFO')}] ${chalk.hex(Colors.LightGray)('2024-09-30T22:00:00.000Z')} Order processed successfully.`
112
+
constexpectedMessage=`[INFO] 2024-09-30T22:00:00.000Z Order processed successfully.`
0 commit comments