chai-jasmine is an extension which provides Jasmine's style expect on top of mocha using chai assertion library.
npm install chai-jasmine --save-dev;
This implementation is based on Jasmine's core directly so all Jasmine's features are supported out of the box :
- Focusing specs
- Mocking Date
- Asynchronous (with the
done()function, Jasmine >= 2.0).
Jasmine's matchers has been rewriten to work on top of chai so features like the Jasmine's custom equality testers won't work anymore. Moreover you'll need to rewrite all your Jasmine custom matchers using chai and include them like so to make them work:
var chai = require('chai-jasmine'); chai.use(require('./your-custom-matchers'));
Note: all features related to the Jasmine's specs runner (like Jasmine.Env()) or reporting won't have any effect anymore.
Note: spies are now cleared up during
afterEach()which may changes a bit the spiecs persistance behavior over specs.