forked from CJWorkbench/cjworkbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupJest.js
26 lines (19 loc) · 799 Bytes
/
setupJest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// https://github.com/facebook/jest/issues/6121#issuecomment-529591574
import { format } from 'util'
import Enzyme from 'enzyme'
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'
import AbortController from 'abort-controller'
import '@testing-library/jest-dom'
Enzyme.configure({ adapter: new Adapter() })
global.AbortController = AbortController
const LoggedToConsoleError = Error
const originalError = global.console.error
global.console.error = function thisTestFailsBecauseItCallsConsoleError (...args) {
originalError(...args)
throw new LoggedToConsoleError(format(...args))
}
const originalWarn = global.console.warn
global.console.warn = function thisTestFailsBecauseItCallsConsoleWarn (...args) {
originalWarn(...args)
throw new LoggedToConsoleError(format(...args))
}