npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

assert-diff

v3.0.4

Published

Drop-in replacement for assert to give diff on deepEqual.

Downloads

17,701

Readme

Greenkeeper badge Known Vulnerabilities

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 works 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

3.0.4 April 2, 2023

  • Upgrade json-diff

3.0.3 April 2, 2023

  • Upgrade deps

3.0.2 April 17, 2020

  • Upgrade deps

3.0.1 April 17, 2020

  • Fix async https://github.com/pihvi/assert-diff/pull/26
  • Upgrade deps
  • Thanks @fent!

3.0.0 March 5, 2020

  • Support async https://github.com/pihvi/assert-diff/pull/23
  • Upgrade deps
  • Thanks @fent!

2.0.3 July 30, 2018

  • Switch to webpack to enable assert(true) style

2.0.2 July 30, 2018

  • Fix usage with assert(true) style

2.0.1 July 30, 2018

  • Fix v. 2.0.0 by adding the built index.js

2.0.0 July 30, 2018

  • Migrate to ES Modules https://github.com/pihvi/assert-diff/pull/17
  • Upgrade deps
  • Thanks @59naga!

1.2.6 Apr 14, 2018

  • Add security build and badges
  • Upgrade deps

1.2.4 Oct 3, 2017

  • Upgrade deps

1.2.3 Sep 10, 2017

  • Upgrade json-diff to 0.5.2

1.2.2 Aug 20, 2017

  • Upgrade json-diff to 0.5.1

1.2.1 Aug 15, 2017

  • Add npm lock file

1.2.0 Mar 11, 2017

  • Support Node 7
  • Diff shown when loggin error object
  • Supports diff in assert.deepStrictEqual

1.1.1 Mar 11, 2017

  • fix console log example to support Node 7

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