jest-mock-warn
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i jest-mock-warn

Weekly Downloads

61

Version

1.1.0

License

MIT

Unpacked Size

6.25 kB

Total Files

5

Last publish

Collaborators

  • posva