AssertionError Diff
Get It
npm install --save assertion-error-diff# or yarn add assertion-error-diff
API
createAssertionError :: string -> a -> a -> AssertionError a
Creates an AssertionError
Example:
throw error
errorToString :: Error -> string
Given an Error
it will create a string representation. If the Error
given
is an AssertionError
it will create a diff of the expected and actual values.
Example:
errorToStringnew Error'foo' // 'Error: foo' errorToStringcreateAssertionError'foo', 'bar', 'baz'// AssertionError: foo// - expected + actual//// bar !== baz
isAssertionError :: Error -> boolean
Given an Error it returns true
if that Error is an AssertionErrorfalse
otherwise.
Example:
isAssertionErrornew Error'foo' // falseisAssertionErrorcreateAssertionError'foo', 'bar', 'baz' // true