Is there framework like Junit for Javascript to test object oriented javascript in Node.js?
javascript, node.js, oop, testing, unit-testing
Solution
Yes, there are a number of them. Answering which is the most popular and/or best is not possible. But two common libraries are Jasmine and Mocha
http://jasmine.github.io/
http://visionmedia.github.io/mocha/
Problem
Are there any best pratices for testing object oriented javascript in Node.js? Like for example if I had the following Cat.js class: ``` function Cat(age, name) { this.name = name || null; this.age = age || null; } Cat.prototype.getAge = function() { return this.age; } Cat.prototype.setAge = function(age) { this.age = age; } Cat.prototype.getName = function(name) { return this.name; } Cat.prototype.setName = function(name) { this.name = name; } Cat.prototype.equals = function(otherCat) { return otherCat.getName() === this.getName() && otherCat.getAge() === this.getAge(); } Cat.prototype.fill = function(newFields) { for (var field in newFields) { if (this.hasOwnProperty(field) && newFields.hasOwnProperty(field)) { if (this[field] !== 'undefined') { this[field] = newFields[field]; } } } }; module.exports = Cat; ``` and I wanted to write test classes that look something like the following like Java's junit tests: ``` var cat1; setUp() { cat1 = new Cat(10, 'Tom'); } ```