forked from toptal/picasso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-setup.ts
33 lines (28 loc) · 837 Bytes
/
jest-setup.ts
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
27
28
29
30
31
32
33
require('@testing-library/jest-dom/extend-expect')
jest.setTimeout(10000)
jest.mock('@toptal/picasso/utils', () => ({
...jest.requireActual('@toptal/picasso/utils'),
isPointerDevice: jest.fn(() => true)
}))
let consoleHasErrorOrWarning = false
const { error, warn } = console
global.console.error = (...args) => {
consoleHasErrorOrWarning = true
error(...args)
}
global.console.warn = (...args) => {
consoleHasErrorOrWarning = true
warn(...args)
}
describe('Throws an error when something is printed to the console', () => {
afterEach(() => {
if (consoleHasErrorOrWarning) {
consoleHasErrorOrWarning = false
throw new Error(`
Jest has detected that an error or warning message
was printed to console. In Picasso we have a zero
console messages policy during the tests run.
`)
}
})
})