Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai-exclude

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-exclude

Exclude keys before a deep equal operation with expect

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
312K
increased by6.6%
Maintainers
1
Weekly downloads
 
Created

What is chai-exclude?

The chai-exclude npm package is a plugin for the Chai assertion library that allows you to exclude specific keys from objects when performing deep equality checks. This is particularly useful when you want to ignore certain properties that may vary or are not relevant to the test.

What are chai-exclude's main functionalities?

Exclude specific keys from deep equality checks

This feature allows you to exclude specific keys from deep equality checks. In the example, the key 'c' is excluded from the comparison, so the objects are considered equal even though their 'c' values differ.

const chai = require('chai');
const chaiExclude = require('chai-exclude');
chai.use(chaiExclude);
const expect = chai.expect;

const obj1 = { a: 1, b: 2, c: 3 };
const obj2 = { a: 1, b: 2, c: 4 };

expect(obj1).excluding('c').to.deep.equal(obj2);

Exclude multiple keys from deep equality checks

This feature allows you to exclude multiple keys from deep equality checks. In the example, the keys 'c' and 'd' are excluded from the comparison, so the objects are considered equal even though their 'c' and 'd' values differ.

const chai = require('chai');
const chaiExclude = require('chai-exclude');
chai.use(chaiExclude);
const expect = chai.expect;

const obj1 = { a: 1, b: 2, c: 3, d: 4 };
const obj2 = { a: 1, b: 2, c: 5, d: 6 };

expect(obj1).excluding(['c', 'd']).to.deep.equal(obj2);

Exclude nested keys from deep equality checks

This feature allows you to exclude nested keys from deep equality checks. In the example, the nested key 'b.y' is excluded from the comparison, so the objects are considered equal even though their 'b.y' values differ.

const chai = require('chai');
const chaiExclude = require('chai-exclude');
chai.use(chaiExclude);
const expect = chai.expect;

const obj1 = { a: 1, b: { x: 2, y: 3 } };
const obj2 = { a: 1, b: { x: 2, y: 4 } };

expect(obj1).excluding('b.y').to.deep.equal(obj2);

Other packages similar to chai-exclude

Keywords

FAQs

Package last updated on 23 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc