Socket
Socket
Sign inDemoInstall

@types/chai-as-promised

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/chai-as-promised

TypeScript definitions for chai-as-promised


Version published
Weekly downloads
853K
increased by8.31%
Maintainers
1
Weekly downloads
 
Created

What is @types/chai-as-promised?

@types/chai-as-promised is a TypeScript type definition package for the chai-as-promised library, which extends Chai with assertions about promises. It allows you to write assertions for promises in a more readable and expressive way.

What are @types/chai-as-promised's main functionalities?

Eventual Fulfillment

This feature allows you to assert that a promise will eventually be fulfilled with a specific value.

const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const expect = chai.expect;

const promise = Promise.resolve(42);
expect(promise).to.eventually.equal(42);

Eventual Rejection

This feature allows you to assert that a promise will eventually be rejected with a specific error.

const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const expect = chai.expect;

const promise = Promise.reject(new Error('Something went wrong'));
expect(promise).to.be.rejectedWith('Something went wrong');

Combining with Other Chai Assertions

This feature allows you to combine promise assertions with other Chai assertions for more complex validations.

const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const expect = chai.expect;

const promise = Promise.resolve({ foo: 'bar' });
expect(promise).to.eventually.have.property('foo').that.equals('bar');

Other packages similar to @types/chai-as-promised

FAQs

Package last updated on 04 Sep 2023

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