mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 17:43:59 +00:00
23 lines
489 B
JavaScript
23 lines
489 B
JavaScript
|
/* eslint-disable no-console */
|
||
|
export default function mockConsole(levels = 'all') {
|
||
|
if (levels === 'all') {
|
||
|
levels = ['trace', 'debug', 'log', 'info', 'warn', 'error']
|
||
|
}
|
||
|
beforeAll(() => {
|
||
|
for (let level of levels) {
|
||
|
console[level] = jest.fn()
|
||
|
}
|
||
|
})
|
||
|
beforeEach(() => {
|
||
|
for (let level of levels) {
|
||
|
console[level].mockClear()
|
||
|
}
|
||
|
})
|
||
|
afterAll(() => {
|
||
|
for (let level of levels) {
|
||
|
console[level].mockRestore()
|
||
|
}
|
||
|
})
|
||
|
return console
|
||
|
}
|