Detalhes do pacote

assertion-error-diff

TylorS11MIT1.0.0

A small library for creating AssertionError diffs

readme (leia-me)

AssertionError Diff

Get It

npm install --save assertion-error-diff
# or
yarn add assertion-error-diff

API

<summary id=createAssertionError>createAssertionError :: string -&gt a -&gt a -&gt AssertionError a</summary>

Creates an AssertionError

Example:

typescript import { createAssertionError } from 'assertion-error-diff' const error = createAssertionError('Not a truthy value', true, false) throw error
<summary id=errorToString>errorToString :: Error -&gt string</summary>

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:

typescript import { errorToString, createAsssertionError } from 'assertion-error-diff' errorToString(new Error('foo')) // 'Error: foo' errorToString(createAssertionError('foo', 'bar', 'baz')) // AssertionError: foo // - expected + actual // // bar !== baz
<summary id=isAssertionError>isAssertionError :: Error -&gt boolean</summary>

Given an Error it returns true if that Error is an AssertionError
false otherwise.

Example:

typescript import { isAssertionError, createAssertionError } from 'assertion-error-diff' isAssertionError(new Error('foo')) // false isAssertionError(createAssertionError('foo', 'bar', 'baz')) // true

changelog (log de mudanças)

1.0.0 (2017-07-06)

Features

  • implement AssertionError class (606b1f1)
  • assertion-error-diff: initial implementation (2f027fa)