mocha-define
v0.2.0
Published
Test definitions for Mocha.js
Downloads
2
Readme
Mocha define
Mocha define is a small plugin for Mocha.js that provides lazy test definitions.
Installation
$ npm install mocha-define --save-dev
Usage
Require mocha-define
in the Mocha tests.
This plugin defines two functions: def
and subject
.
For example:
describe('Car', function() {
def('engine', function() {
return new Engine;
});
def('options', function() {
return {};
});
subject(function() {
return Car(this.engine, this.options);
});
describe('#start', function() {
it('starts the engine', function(done) {
this.engine.start = done;
this.subject.pressStartButton();
});
});
describe('#burnout', function() {
it('trashes the tires', function(done) {
this.subject.on('burnout', function(status) {
if (status.tires === 'GARBAGE') {
done();
}
this.subject.doThatBurnout();
});
});
});
});
Contribution
Be sure to!
Implement the functionality with a test and send us a pull request on Github.