Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@types/chai-as-promised
Advanced tools
@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.
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');
Jest is a JavaScript testing framework that comes with built-in support for promises. It allows you to write tests for asynchronous code using async/await or promise-based syntax. Compared to chai-as-promised, Jest provides a more integrated testing experience with built-in matchers for promises.
Sinon is a library for creating spies, stubs, and mocks in JavaScript. While it is not specifically focused on promise assertions, it can be used in conjunction with other libraries like Chai to test asynchronous code. Sinon provides more comprehensive tools for mocking and spying on asynchronous functions compared to chai-as-promised.
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser. It allows you to use any assertion library, including Chai and chai-as-promised. Mocha itself does not provide promise assertions but can be used with chai-as-promised to achieve similar functionality.
npm install --save @types/chai-as-promised
This package contains type definitions for chai-as-promised (https://github.com/domenic/chai-as-promised/).
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/chai-as-promised
Additional Details
These definitions were written by jt000 https://github.com/jt000, Yuki Kokubun https://github.com/Kuniwak.
FAQs
TypeScript definitions for chai-as-promised
We found that @types/chai-as-promised demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.