mirror of
https://github.com/coder/coder.git
synced 2026-10-29 17:44:33 +08:00
refactor: clean up types in jest.setup.ts (#4285)
This commit is contained in:
+3
-7
@@ -38,16 +38,12 @@ afterAll(() => server.close())
|
|||||||
// For now, I limited this to just 'error' - but failing on warnings
|
// For now, I limited this to just 'error' - but failing on warnings
|
||||||
// would be a nice next step! We may need to filter out some noise
|
// would be a nice next step! We may need to filter out some noise
|
||||||
// from material-ui though.
|
// from material-ui though.
|
||||||
const CONSOLE_FAIL_TYPES = ["error" /* 'warn' */]
|
const CONSOLE_FAIL_TYPES = ["error" /* 'warn' */] as const
|
||||||
|
|
||||||
// Throw errors when a `console.error` or `console.warn` happens
|
// Throw errors when a `console.error` or `console.warn` happens
|
||||||
// by overriding the functions
|
// by overriding the functions
|
||||||
CONSOLE_FAIL_TYPES.forEach((logType: string) => {
|
CONSOLE_FAIL_TYPES.forEach((logType: typeof CONSOLE_FAIL_TYPES[number]) => {
|
||||||
// Suppressing the no-explicit-any to override certain console functions for testing
|
global.console[logType] = <Type>(format: string, ...args: Type[]): void => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
const consoleAsAny = global.console as any
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
consoleAsAny[logType] = (format: string, ...args: any[]): void => {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failing due to console.${logType} while running test!\n\n${util.format(format, ...args)}`,
|
`Failing due to console.${logType} while running test!\n\n${util.format(format, ...args)}`,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user