Chai is available for both node.js and the browser using anytest framework you like. There are also a number of other toolsthat include Chai.
Package is available throughnpm:
npminstallchai
Recommend adding it topackage.json
devDependencies using a*
as the version tag.This will ensure that you always have the most recent version after runningnpminstall
,which can be especially powerful when paired with a continuous integration tool.
"devDependencies":{"chai":"*","mocha":"*"},"//":"mocha is our preference, but you can use any test runner you like"
Include the chai browser build in your testing suite.
<scriptsrc="chai.js"type="text/javascript"></script>
This will providechai
as a global object, ordefine
it if you are using AMD.
The latest tagged version will be available for hot-linking athttp://chaijs.com/chai.js.If you prefer to host yourself, use thechai.js
file from the root of the github project.We recommend that you always use a version tag as your starting point, so thetag download list is the best place to start.
Currently supports all modern browsers: IE 9+, Chrome 7+, FireFox 4+, Safari 5+. Please notethat theshould
style is currently not compatible with IE9.
If you want to know if your browser is compatible, run theonline test suite.
For testing your Ruby on Rails application using Chai assertionsand the Mocha test framework, check out Konacha – a moderntest harness that takes full advantage of Rails 3 features such as theasset pipeline and engines.