@@ -2,6 +2,7 @@ import { expect } from "chai";
2
2
3
3
import * as logger from "../src/logger" ;
4
4
import { setGlobalOptions } from "../src/v2" ;
5
+ import { getGlobalOptions } from "../src/v2/options" ;
5
6
6
7
describe ( "logger" , ( ) => {
7
8
const stdoutWrite = process . stdout . write . bind ( process . stdout ) ;
@@ -221,24 +222,37 @@ describe("logger", () => {
221
222
} ) ;
222
223
223
224
describe ( "error logging stacktrace" , ( ) => {
224
- it ( "should include stacktrace in error logs" , ( ) => {
225
+ const defaultOptions = getGlobalOptions ( ) ;
226
+
227
+ beforeEach ( ( ) => {
228
+ setGlobalOptions ( defaultOptions ) ;
229
+ } ) ;
230
+
231
+ it ( "when disableErrorLoggingStacktrace is set to false, should include stacktrace in error logs" , ( ) => {
225
232
const message = "Test error with stacktrace" ;
233
+ setGlobalOptions ( {
234
+ disableErrorLoggingStacktrace : false ,
235
+ } ) ;
226
236
logger . error ( message ) ;
227
237
const messageOutput = JSON . parse ( lastErr . trim ( ) ) . message ;
228
238
229
239
expect ( messageOutput ) . to . include ( `Error: ${ message } ` ) ;
230
240
} ) ;
231
241
232
- it ( "when disableErrorLoggingTraceback is set to true, should not log stacktrace" , ( ) => {
233
- const message = "Test error with traceback disabled" ;
242
+ it ( "when disableErrorLoggingStacktrace is set to true, should not include stacktrace in error logs " , ( ) => {
243
+ const message = "Test error with stacktrace disabled" ;
234
244
setGlobalOptions ( {
235
- disableErrorLoggingTraceback : true ,
245
+ disableErrorLoggingStacktrace : true ,
236
246
} ) ;
237
247
logger . error ( message ) ;
238
248
expectStderr ( {
239
249
severity : "ERROR" ,
240
250
message : message ,
241
251
} ) ;
242
252
} ) ;
253
+
254
+ afterEach ( ( ) => {
255
+ setGlobalOptions ( defaultOptions ) ;
256
+ } ) ;
243
257
} ) ;
244
258
} ) ;
0 commit comments