NodeJS has a lot of different package for unit testing. I'll investigate more when I can. For now, I like this one:
It's pretty simple.
For example:
var hello = function() {
return "Hello World!";
}
const test = require('tape');
test("unit tests", function(t) {
t.equal(hello(), "Hello World!", "- hello() test");
t.end();
});
Outputs:
TAP version 13
# unit tests
ok 1 - hello() test
Basic usage
Testing for strings that match a RegExp
The tape.equal(a, b, msg) method checks for equality. Sometimes it is convenient to check for a RegExp instead. Just use tape.ok().For instance:
var hello = function() {
return "Hello World!";
}
const test = require('tape');
test("unit tests", function(t) {
t.ok(/Hello/.test(hello()), "- hello() test");
t.end();
});
Gives the same output as the previous example.