Skip to content

Commit

Permalink
fix: jestLogger to include stacktrace always (not just for error level)
Browse files Browse the repository at this point in the history
Cause it should be safe to print stacktraces in test environment
  • Loading branch information
kirillgroshkov committed Nov 27, 2021
1 parent 1c83f29 commit b8de50e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/test/setupJest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// console.log('setupJest.ts')

import { jestOffline } from '../jestOffline.util'
import { jestLog, jestLogger } from '../testing'

jestOffline()

console.log = console.warn = jestLog
console.error = jestLogger.error.bind(jestLogger)
4 changes: 2 additions & 2 deletions src/testing/testing.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export function silentConsole(): void {
console.table = () => {}
}

export const jestLogger = commonLoggerCreate((level, args) => {
export const jestLogger = commonLoggerCreate((_level, args) => {
if (process.env['JEST_SILENT']) return // no-op
process.stdout.write(
args
.map(a =>
inspectAny(a, {
includeErrorStack: level === 'error',
includeErrorStack: true,
}),
)
.join(' ') + '\n',
Expand Down

0 comments on commit b8de50e

Please sign in to comment.