-
Notifications
You must be signed in to change notification settings - Fork 0
Jasmine TDD
tdkehoe edited this page Sep 11, 2015
·
23 revisions
#Directory structure and initialization
In the project root directory, run
jasmine init
This creates two directories and a file:
spec/support/jasmine.json
Next, create two files:
touch spec/spec.js
touch app.js
The directory should now look like:
spec/support/jasmine.json
spec/spec.js
app.js
#app.js app.js is an object of keys and methods. The name of the object is module.exports.
module.exports = {
nameOfTest: function() {
// code goes here;
return anyName;
},
anotherTest: function() {
// more code;
// return somethingElse;
}
};
#spec.js In spec.js:
var app = require('./../app.js');
var inputData = ['red', 'green', 'blue'];
describe('Test nameOfTest', function() {
it('Description of code', function() {
expect(app.nameOfTest(inputData)).toEqual(outputData);
});
});
var moreInputData = [...]
describe('Test anotherTest', function() {
it('Description of code', function() {
expect(app.nameOfOtherTest(moreInputData)).toEqual(outputData);
});
});
#Run jasmine Run the tests from the root directory with the command
jasmine