A small testing library for the browser
Include the test.js
file:
<script src="https://cdn.rawgit.com/kamerontanseli/testr/master/build/test.min.js"></script>
Standard Test:
Testr.test('1 + 1 = 2', function(assert){
assert.equal(1 + 1, 2);
});
Async test:
Testr.test('Async 1 + 1 = 2', function(assert, done){
setTimeout(function(){
assert.equal(1 + 1, 3);
done();
});
}, true);
Assertion Types:
assert.equalArr([1,2,3], [1,2,3]); // comparison between arrays (not nested)
assert.equal(2, 2); // strict equal comparison
assert.notOkay(false); // check if false
assert.okay(true); // check if true
Run tests:
Testr.start();
Output:
START 1 + 1 = 2
SUCCESS: 1 + 1 = 2
END 1 + 1 = 2
START Async 1 + 1 = 2
FAILURE: Async 1 + 1 = 2 ==> Error: 2 is not equal to 3
END Async 1 + 1 = 2