@@ -12,16 +12,10 @@ test('logging', () => {
12
12
const TAG = 'tests:logging'
13
13
const log = getLogger ( TAG )
14
14
15
- // Will collect logs in this array
16
15
let events : LogData [ ] = [ ]
17
16
addHandler ( data => events . push ( data ) )
18
17
19
- const consoleError = jest . spyOn ( console , 'error' )
20
-
21
18
log . debug ( 'a debug message' )
22
- expect ( consoleError ) . toHaveBeenCalledWith (
23
- expect . stringMatching ( / D E B U G ( .* ) ? a d e b u g m e s s a g e / )
24
- )
25
19
expect ( events . length ) . toBe ( 1 )
26
20
expect ( events [ 0 ] . tag ) . toBe ( TAG )
27
21
expect ( events [ 0 ] . level ) . toBe ( LogLevel . debug )
@@ -34,9 +28,6 @@ test('logging', () => {
34
28
message : 'an info message' ,
35
29
stack : 'Just a made up trace'
36
30
} )
37
- expect ( consoleError ) . toHaveBeenCalledWith (
38
- expect . stringMatching ( / I N F O ( .* ) ? a n i n f o m e s s a g e / )
39
- )
40
31
expect ( events . length ) . toBe ( 2 )
41
32
expect ( events [ 1 ] . tag ) . toBe ( TAG )
42
33
expect ( events [ 1 ] . level ) . toBe ( LogLevel . info )
@@ -50,6 +41,20 @@ test('logging', () => {
50
41
expect ( events [ 3 ] . level ) . toBe ( LogLevel . error )
51
42
} )
52
43
44
+ test ( 'TTY' , ( ) => {
45
+ const log = getLogger ( 'tests:tty' )
46
+
47
+ // Fake that we are using a TTY device
48
+ process . stderr . isTTY = true
49
+ const consoleError = jest . spyOn ( console , 'error' )
50
+
51
+ log . error ( 'an error message' )
52
+
53
+ expect ( consoleError ) . toHaveBeenCalledWith (
54
+ expect . stringMatching ( / E R R O R ( .* ) ? a n e r r o r m e s s a g e / )
55
+ )
56
+ } )
57
+
53
58
test ( 'non-TTY' , ( ) => {
54
59
const log = getLogger ( 'tests:non-tty' )
55
60
0 commit comments