Skip to content

Commit ce95344

Browse files
authored
refactor: clean up types in jest.setup.ts (#4285)
1 parent cd4ab97 commit ce95344

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

site/jest.setup.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,12 @@ afterAll(() => server.close())
3838
// For now, I limited this to just 'error' - but failing on warnings
3939
// would be a nice next step! We may need to filter out some noise
4040
// from material-ui though.
41-
const CONSOLE_FAIL_TYPES = ["error" /* 'warn' */]
41+
const CONSOLE_FAIL_TYPES = ["error" /* 'warn' */] as const
4242

4343
// Throw errors when a `console.error` or `console.warn` happens
4444
// by overriding the functions
45-
CONSOLE_FAIL_TYPES.forEach((logType: string) => {
46-
// Suppressing the no-explicit-any to override certain console functions for testing
47-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
48-
const consoleAsAny = global.console as any
49-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
50-
consoleAsAny[logType] = (format: string, ...args: any[]): void => {
45+
CONSOLE_FAIL_TYPES.forEach((logType: typeof CONSOLE_FAIL_TYPES[number]) => {
46+
global.console[logType] = <Type>(format: string, ...args: Type[]): void => {
5147
throw new Error(
5248
`Failing due to console.${logType} while running test!\n\n${util.format(format, ...args)}`,
5349
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy