File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -38,16 +38,12 @@ afterAll(() => server.close())
38
38
// For now, I limited this to just 'error' - but failing on warnings
39
39
// would be a nice next step! We may need to filter out some noise
40
40
// from material-ui though.
41
- const CONSOLE_FAIL_TYPES = [ "error" /* 'warn' */ ]
41
+ const CONSOLE_FAIL_TYPES = [ "error" /* 'warn' */ ] as const
42
42
43
43
// Throw errors when a `console.error` or `console.warn` happens
44
44
// 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 => {
51
47
throw new Error (
52
48
`Failing due to console.${ logType } while running test!\n\n${ util . format ( format , ...args ) } ` ,
53
49
)
You can’t perform that action at this time.
0 commit comments