Coder Social home page Coder Social logo

chai-deep-match's Introduction

chai-deep-match

GitHub Latest Release Build Status Coverage Status Dependency Status Dev Dependency Status

Extends Chai with an assertion for deeply matching objects (i.e. subset equality checking).

Install

$ npm install --save chai
$ npm install --save chai-deep-match

Usage

var chai = require('chai');
var chaiDeepMatch = require('chai-deep-match');

chai.use( chaiDeepMatch );


chai.expect( { a: 'foo', b: 'bar', c: 'baz' } ).to.deep.match( { a: 'foo', c: 'baz' } );
// =>  pass

chai.expect( { a: 'foo', b: 'bar', c: 'baz' } ).to.not.deep.match( { a: 'fuzz', c: 'baz' } );
// =>  pass

Note about URL objects

This module also supports WHATWG URL objects, as introduced in Node 7.x (and backported into Node 6.x, it seems). However, it is important to note that the behavior by which it compares two URL objects will only consider them deeply matched if they are a full 100% match rather than a "subset" match. Hopefully this behavior is acceptable to those making use of it! ๐Ÿ™

License

Copyright (c) 2016-2018, James M. Greene (MIT License)

chai-deep-match's People

Contributors

jamesmgreene avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chai-deep-match's Issues

keywords to increase discoverability

I wish I had found this library last year.

Try using these plugin keywords to better categorize this on the chai.js website:

  • contains
  • like
  • similar
  • subset

URL support?

const {URL} = require("url");
const url = "http://domain/";

expect( new URL(url) ).to.deep.match( new URL(url) );
expect({ key:new URL(url) }).to.deep.match({ key:new URL(url) });  // throws

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.