All Projects → debitoor → chai-subset

debitoor / chai-subset

Licence: MIT license
"containSubset" object properties matcher for Chai

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to chai-subset

React Base
atSistemas React/Redux Isomorphic Platform
Stars: ✭ 82 (+0%)
Mutual labels:  chai
Earl
☕ Ergonomic, modern and type-safe assertion library for TypeScript
Stars: ✭ 153 (+86.59%)
Mutual labels:  chai
corewar
Typescript implementation of red code parser and core simulator for the classic game Corewar
Stars: ✭ 46 (-43.9%)
Mutual labels:  chai
Typescript Restful Starter
Node.js + ExpressJS + Joi + Typeorm + Typescript + JWT + ES2015 + Clustering + Tslint + Mocha + Chai
Stars: ✭ 97 (+18.29%)
Mutual labels:  chai
Cracking The Coding Interview Javascript Solutions Ctci
Javascript solutions to Cracking the Coding Interview (CTCI)
Stars: ✭ 139 (+69.51%)
Mutual labels:  chai
Redux Actions Assertions
Simplify testing of redux action and async action creators
Stars: ✭ 177 (+115.85%)
Mutual labels:  chai
Preact Jsx Chai
✅ Add JSX assertions to Chai, with support for Preact Components.
Stars: ✭ 56 (-31.71%)
Mutual labels:  chai
minimal-hapi-react-webpack
Minimal Hapi + React + Webpack + HMR (hot module reloading) Sandbox
Stars: ✭ 55 (-32.93%)
Mutual labels:  chai
Postman Bdd
A BDD test framework for Postman and Newman
Stars: ✭ 139 (+69.51%)
Mutual labels:  chai
fetch-action-creator
Fetches using standardized, four-part asynchronous actions for redux-thunk.
Stars: ✭ 28 (-65.85%)
Mutual labels:  chai
Chai
ERC20 wrapper over the Dai Savings Rate
Stars: ✭ 118 (+43.9%)
Mutual labels:  chai
Javascript Testing Best Practices
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)
Stars: ✭ 13,976 (+16943.9%)
Mutual labels:  chai
chai
BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
Stars: ✭ 7,842 (+9463.41%)
Mutual labels:  chai
Karma Webpack Example
Karma + Webpack + Mocha + Chai + Istanbul
Stars: ✭ 88 (+7.32%)
Mutual labels:  chai
TvrboReact
Dream starter project: React, Redux, React Router, Webpack
Stars: ✭ 13 (-84.15%)
Mutual labels:  chai
Openapivalidators
Use Jest or Chai to assert that HTTP responses satisfy an OpenAPI spec
Stars: ✭ 77 (-6.1%)
Mutual labels:  chai
Chai Immutable
Chai assertions for Facebook's Immutable library for JavaScript collections
Stars: ✭ 161 (+96.34%)
Mutual labels:  chai
react-testing-mocha-chai-enzyme
A solid test setup for React components with Mocha, Chai, Sinon, Enzyme in a Webpack/Babel application.
Stars: ✭ 48 (-41.46%)
Mutual labels:  chai
js-stack-from-scratch
🌺 Russian translation of "JavaScript Stack from Scratch" from the React-Theming developers https://github.com/sm-react/react-theming
Stars: ✭ 394 (+380.49%)
Mutual labels:  chai
chai-exclude
Exclude keys to compare from a deep equal operation with chai expect or assert.
Stars: ✭ 33 (-59.76%)
Mutual labels:  chai

chai-subset npm version Build Status devDependency Status Coverage Status NSP Status

"containSubset" object properties matcher for Chai assertion library

Installation

npm install --save-dev chai-subset

Usage

common.js

var chai = require('chai');
var chaiSubset = require('chai-subset');
chai.use(chaiSubset);

in your spec.js

var obj = {
	a: 'b',
	c: 'd',
	e: {
		foo: 'bar',
		baz: {
			qux: 'quux'
		}
	}
};
	
expect(obj).to.containSubset({
	a: 'b',
	e: {
		baz: {
			qux: 'quux'
		}
	}
});

// or using a compare function
expect(obj).containSubset({
	a: (expectedValue) => expectedValue,
	c: (expectedValue) => expectedValue === 'd'
})

// or with 'not'
expect(obj).to.not.containSubset({
	g: 'whatever'
});

Also works good with arrays and should interface

var list = [{a: 'a', b: 'b'}, {v: 'f', d: {z: 'g'}}];

list.should.containSubset([{a:'a'}]); //Assertion error is not thrown
list.should.containSubset([{a:'a',  b: 'b'}]); //Assertion error is not thrown

list.should.containSubset([{a:'a', b: 'bd'}]); 
/*throws
AssertionError: expected
[
    {
        "a": "a",
        "b": "b"
    },
    {
        "v": "f",
        "d": {
            "z": "g"
        }
    }
]
to contain subset 
[ { a: 'a', b: 'bd' } ]
*/

and with assert interface

assert.containSubset({a: 1, b: 2}, {a: 1});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].