1.1.0 • Published 4 years ago

jest-mock-warn v1.1.0

Weekly downloads
126
License
MIT
Repository
github
Last release
4 years ago

jest-mock-warn npm package

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)

License

MIT

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago