Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

assertion-error-formatter

charlierudolph5.7mMIT3.0.0

Format errors to display a diff between the actual and expected

readme

Node Assertion Error Formatter

Format errors to display a diff between the actual and expected

Originally extracted from mocha

Usage

import {format} from 'assertion-error-formatter'

format(error)

API Reference

format(error [, options])

  • error: a javascript error
  • options: An object with the following keys:
    • colorFns: An object with the keys 'diffAdded', 'diffRemoved', 'errorMessage', 'errorStack'. The values are functions to colorize a string, each defaults to identity.
    • inlineDiff: boolean (default: false)
      • toggle between inline and unified diffs

changelog

3.0.0 (2019-08-20)

  • drop support for Node 4, 6
  • support Node 10, 12

2.0.1

  • support object errors without stack
  • better formatting for errors where the stack does not include the message

2.0.0

  • support string errors
  • update options structure

      // Before
      {
        colorDiffAdded,
        colorDiffRemoved,
        colorErrorMessage,
        inlineDiffs
      }
    
      // After
      {
        colorFns: {
          diffAdded,
          diffRemoved,
          errorMessage,
          errorStack
        },
        inlineDiffs
      }

1.0.1

  • Initial release