Skip to content

Instantly share code, notes, and snippets.

@Madhuka
Created November 14, 2013 08:04
Show Gist options
  • Save Madhuka/7463140 to your computer and use it in GitHub Desktop.
Save Madhuka/7463140 to your computer and use it in GitHub Desktop.
User.js testing with mocha
function User(name) {
this.name = name;
}
User.prototype.getUserName = function() {
return this.name;
};
module.exports = User;
var should = require('should');
var User = require("./User.js");
var assert = require("assert");
var user;
beforeEach(function() {
console.log('\nbefore every test :: adding user jhon to the system');
user = new User('Jhon');
//if all test you ned jhon user to chakc create in here
})
afterEach(function() {
console.log('after every test :: removing user from the system');
user = null;
})
describe('Adding a new User', function() {
it('user should have a name', function() {
console.log('starting user testing ');
user.should.have.property('name', 'Jhon');
console.log('end user test');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment