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

chai-quantifiers

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-quantifiers

Array quantifier assertions for chai assertion library

  • 1.0.18
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

chai-quantifiers

Array quantifier assertions for Chai assertion library.

main workflow Coverage Status Maintainability node code style Types License Status

Install

npm install --save-dev chai chai-quantifiers

Usage

There are three assertions available, applicable to arrays.

  • containAll -- Asserts that all array items are true in respect to a predicate.
  • containOne -- Asserts that at least one array item is true in respect to a predicate.
  • containExactlyOne -- Asserts that exactly one array item is true in respect to a predicate.

A quick example:

const chai = require('chai');
const chaiQuantifiers = require('chai-quantifiers');

chai.use(chaiQuantifiers);

const { expect } = chai;

describe('chai-quantifiers', () => {
  it('containAll should be true if all items are true', () => {
    expect([0, 1, 2, 3]).to.containAll(item => item < 4);
  });
  it('containOne should be true if at least one item is true', () => {
    expect([0, 1, 2, 3]).to.containOne(item => item >= 2);
  });
  it('containExactlyOne should be true if exactly one item is true', () => {
    expect([0, 1, 2, 3]).to.containExactlyOne(item => item === 2);
  });
});

This module also includes types for TypeScript.

Keywords

FAQs

Package last updated on 26 Feb 2024

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