$ npm install karma-chai-plugins --save-dev
chai and plugins you need to the
frameworks key in your Karma configuration:
=configset# frameworks to useframeworks: 'mocha''chai''chai-as-promised'# ...
Note: for using sinon, it is sufficient to add
sinon-chai in karma frameworks. No need to add
Same as Chai.js: IE 9+, Chrome 7+, FireFox 4+, Safari 5+ except
should style that is currently not compatible with IE 9.
Consider karma-expect, if you need run tests in IE8 and lower.
Currently, in order to use Chai-as-Promised when running tests within PhantomJS, a polyfill for
Function.prototype.bind must be supplied. This plugin includes such a polyfill. If your code under test is intended to be run under PhantomJS in production, bear this in mind! You may need to supply your own polyfill in your project.
Function.prototype.bind polyfill will be removed in the future v1.0 release of karma-chai-plugins.
chai-dom and chai-jquery can't work together, choose one of them.
requirejs in tests, but for now it should be stated in frameworks before
chai and other plugins:
=configset# frameworks to useframeworks: 'mocha''requirejs''chai''chai-as-promised'# ...
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using