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.
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. It provides functions to express assertions in a readable language, supporting both 'should' and 'expect' style syntaxes, as well as a traditional 'assert' style interface.
Should Style Assertions
Allows you to write assertions in a more human-readable form, which reads like English. The 'should' style extends each object with a 'should' property to start your chain.
chai.should();
var should = chai.should();
should.exist(value, 'value should not be null or undefined');
Expect Style Assertions
Provides a function called 'expect' to make assertions about values. This style is similar to 'should' but does not extend any objects, which is useful for working with libraries that don't allow object extensions.
var expect = chai.expect;
expect(value).to.exist.and.be.an('object');
Assert Style Assertions
Offers a more traditional testing interface, which is similar to Node.js' core 'assert' module but with more capabilities and better error messages.
var assert = chai.assert;
assert.typeOf(value, 'string', 'value is a string');
Chainable Language Chains
Provides chainable getters to improve the readability of your assertions, allowing you to write more expressive tests.
expect(value).to.be.an('array').that.includes(3);
Plugins
Supports plugins to extend its core functionalities, which can be used to add new assertions, matchers, or methods to the library.
var chaiHttp = require('chai-http');
chai.use(chaiHttp);
Jest is a delightful JavaScript Testing Framework with a focus on simplicity. It works out of the box for any React project and includes its own assertion library, which provides a similar but more integrated testing experience compared to Chai.
Jasmine is a behavior-driven development framework for testing JavaScript code. It does not rely on browsers, DOM, or any JavaScript framework, making it suitable for websites, Node.js projects, or anywhere JavaScript can run. It has its own assertion syntax that is somewhat similar to Chai's 'expect' syntax.
Expect.js is a minimalistic BDD-style assertions library that can be considered an alternative to Chai's 'expect' interface. It provides a similar API but is no longer actively maintained.
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
For more information view the documentation.
Chai is available for both node.js server-side and the browser.
Package is available through npm:
npm install chai
Recommend adding it to package.json devDependancies.
Include the chai browser build in your testing suite.
<script src="chai.js" type="text/javascript"></script>
Currently supports all modern browsers: IE 9+, Chrome 7+, FireFox 4+, Safari 5+
Chai tests itself in the browser using mocha.
Have a look at the test/browser
folder for an example.
(The MIT License)
Copyright (c) 2011 Jake Luer jake@alogicalparadox.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
The npm package chai receives a total of 10,793,736 weekly downloads. As such, chai popularity was classified as popular.
We found that chai 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.