Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63da850

Browse files
committed
fix: incomplete message when intercepting console logger
I was getting a message like "Warning: Failed type %s: %s%s".
1 parent 9a89bf4 commit 63da850

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

site/jest.setup.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import "@testing-library/jest-dom"
22
import crypto from "crypto"
3+
import * as util from "util"
34
import { server } from "./src/testHelpers/server"
45

56
// Polyfill the getRandomValues that is used on utils/random.ts
@@ -43,8 +44,9 @@ CONSOLE_FAIL_TYPES.forEach((logType: string) => {
4344
// Suppressing the no-explicit-any to override certain console functions for testing
4445
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4546
const consoleAsAny = global.console as any
46-
consoleAsAny[logType] = (message: string): void => {
47-
throw new Error(`Failing due to console.${logType} while running test!\n\n${message}`)
47+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
48+
consoleAsAny[logType] = (format: string, ...args: any[]): void => {
49+
throw new Error(`Failing due to console.${logType} while running test!\n\n${util.format(format, ...args)}`)
4850
}
4951
})
5052

0 commit comments

Comments
 (0)