Git Product home page Git Product logo

assert-diff's Introduction

Drop-in replacement for assert to give colored diff on command-line with deepEqual.

This exists to give better diff on error when comparing objects or arrays with Mocha.

Should work on *nix shells.

Also has more asserts from https://npmjs.org/package/assert-plus

Usage

var assert = require('assert-diff')

it('diff deep equal with message', function() {
  assert.deepEqual({pow: "boom", same: true, foo: 2}, {same: true, bar: 2, pow: "bang"}, "this should fail")
})

Should give you:

Strict mode

By default everything should work as with Node's deepEqual. Using strict mode is probably what you want. At least is for me. The following example will pass with Node's deepEqual but will fail using strict mode:

var assert = require('assert-diff')
assert.options.strict = true

it('strict diff deep equal', function() {
  assert.deepEqual({a: 1, b: 2}, {a: true, b: "2"}, "this should fail")
})

Should give you:

Release notes

1.1.0 Aug 19, 2016

  • Upgrade assert-plus 0.1.5 -> 1.0.0

1.0.1 Feb 18, 2015

  • Default behaviour back to non strict to be drop-in replacement for Node assert

1.0.0 Feb 18, 2015

  • Support assert in constructor e.g. assert(true)

0.0.x before 2015

  • Initial implementation

License

Apache 2.0

assert-diff's People

Contributors

krinkle avatar pihvi avatar wltsmrz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.