catch-error

1.0.0 • Public • Published

Catch Error

A handy helper to make testing whether an error was thrown just a little bit nicer.

// some test setup...
function myFunc(arg1, arg2) {
  throw new Error('wat')
}
 
var error = catchError({ func: myFunc, args: ['hi', 'there'] })
expect(error).to.be.an.instanceof(Error)
expect(error.message).to.equal('wat')

You may also need to set context for your function if it has been constructed with the new keyword. You can do this by passing in context like so:

var error = catchError({ func: myFunc, context: this })

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i catch-error

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • coder_stu
  • digitalsadhu