jest-mock-warn
v1.1.0
Published
Assert console.warn calls
Downloads
551
Readme
jest-mock-warn
mock
console.warn
Installation
yarn add -D jest-mock-warn
Usage
import { mockWarn } from 'jest-mock-warn'
function myFunction() {
if (!arguments.length) console.warn('provide an argument')
}
describe('my tests', () => {
mockWarn()
it('warns when called without arguments', () => {
myFunction()
expect('provide an argument').toHaveBeenWarned()
expect('provide an argument').toHaveBeenWarnedTimes(1)
expect('provide an argument').toHaveBeenLastWarned()
})
})
API
toHaveBeenWarned()
toHaveBeenWarnedLast()
toHaveBeenWarnedTimes(n: number)