jsTestMore is an easy to use automated test framework for your JavaScript code.
The jsTestMore API is a based on that of the Test::More perl module. It's not as complex and powerful as jsUnit, but it makes up for that by being easy to use.
You can download jsTestMore here. jsTestMore is distributed under an MIT style license. See the reference documentation.
Example test
// use the browser to generate html output
// it should be easy to add different UIs
// but that part isn't done yet.
// the argument must be an element ID to
// add the output to.
testmore.ui.browser("testoutput");
make_plans(function () {
// plan a series of tests. arguments are
// number of tests to run, title of the testseries,
// and a function that runs the tests
plan(9,"These tests should all be OK.", function() {
ok(true,"boolean");
ok(!false,"boolean2");
is(300,300,"is number");
is("blabla","blabla","is string");
isnt(300,350,"isnt number");
isnt("blabla","bliepbliep","isn't string");
can("blabla","toString","can");
like("blabla",/bla/,"like");
unlike("blabla",/other/,"unlike");
});
// plan another series of tests.
// output will be appended
plan(9,"These tests should all fail.", function() {
ok(false,"boolean");
ok(!true,"boolean2");
is(305,300,"is number");
is("blabla","bliepbliep","is string");
isnt(300,300,"isnt number");
isnt("blabla","blabla","isn't string");
can("blabla","doesntExist","can");
like("blabla",/other/,"like");
unlike("blabla",/bla/,"unlike");
});
// plan another series of tests.
// output will be appended
plan(4,"Test 1 and 3 should fail, 2 and 4 should succeed.", function() {
ok(false,"boolean");
ok(true,"boolean2");
is(305,300,"is number");
is("blabla","blabla","is string");
});
});
