mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-12 00:53:55 +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
|
|
}
|