@@ -27,9 +27,11 @@ const PROCESS_CWD_TARGET_PATH = path.resolve(__dirname)
27
27
let orgCwd // for process.cwd mock
28
28
let orgExit // for process.exit mock
29
29
let spyLog
30
+ let spyWarn
30
31
let spyError
31
32
beforeEach ( ( ) => {
32
33
spyLog = jest . spyOn ( global . console , 'log' )
34
+ spyWarn = jest . spyOn ( global . console , 'warn' )
33
35
spyError = jest . spyOn ( global . console , 'error' )
34
36
orgCwd = process . cwd
35
37
process . cwd = jest . fn ( ( ) => PROCESS_CWD_TARGET_PATH ) // mock: process.cwd
@@ -38,6 +40,7 @@ beforeEach(() => {
38
40
39
41
afterEach ( ( ) => {
40
42
spyError . mockRestore ( )
43
+ spyWarn . mockRestore ( )
41
44
spyLog . mockRestore ( )
42
45
jest . clearAllMocks ( )
43
46
process . exit = orgExit
@@ -72,7 +75,7 @@ test('--provider: not found', async () => {
72
75
} )
73
76
74
77
// verify
75
- expect ( spyLog ) . toHaveBeenCalledWith ( 'Not found ./404-provider.js provider' )
78
+ expect ( spyError ) . toHaveBeenCalledWith ( 'Not found ./404-provider.js provider' )
76
79
} )
77
80
78
81
test ( 'not specified --target and --targetPaths' , async ( ) => {
@@ -86,7 +89,7 @@ test('not specified --target and --targetPaths', async () => {
86
89
} )
87
90
88
91
// verify
89
- expect ( spyLog ) . toHaveBeenCalledWith ( 'You need to specify either --target or --target-paths' )
92
+ expect ( spyError ) . toHaveBeenCalledWith ( 'You need to specify either --target or --target-paths' )
90
93
} )
91
94
92
95
test ( '--target option' , async ( ) => {
@@ -111,6 +114,9 @@ test('--target option', async () => {
111
114
112
115
// verify with snapshot
113
116
expect ( spyLog . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( )
117
+ // NOTE: cannot detect process.exit calling in `fail` ...
118
+ // expect(spyWarn).toHaveBeenCalledWith('There are differences!')
119
+ // expect(process.exit).toHaveBeenCalledWith(64)
114
120
} )
115
121
116
122
test ( '--locale option' , async ( ) => {
@@ -135,6 +141,9 @@ test('--locale option', async () => {
135
141
136
142
// verify with snapshot
137
143
expect ( spyLog . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( )
144
+ // NOTE: cannot detect process.exit calling in `fail` ...
145
+ // expect(spyWarn).toHaveBeenCalledWith('There are differences!')
146
+ // expect(process.exit).toHaveBeenCalledWith(64)
138
147
} )
139
148
140
149
test ( '--target-paths option' , async ( ) => {
@@ -159,4 +168,7 @@ test('--target-paths option', async () => {
159
168
160
169
// verify with snapshot
161
170
expect ( spyLog . mock . calls [ 1 ] [ 0 ] ) . toMatchSnapshot ( )
171
+ // NOTE: cannot detect process.exit calling in `fail` ...
172
+ // expect(spyWarn).toHaveBeenCalledWith('There are differences!')
173
+ // expect(process.exit).toHaveBeenCalledWith(64)
162
174
} )
0 commit comments