I have a (JavaScript) repository on github which I would like to set up a test harness for.
It seems ‘tape’ and ‘testling’ should do what I want (minimal lightweight solution with pretty github badges), unless anyone has alternative solutions, but I’m struggling on how to set things up.
I've never used node.js, and it seems that tape, and testling (and all associated examples) are focused on node.js.
Can anyone advise on a minimal configuration for a simple client-side JavaScript library test harness? I guess(?) I need nodejs, npm, package.json, etc to run tape/testling locally, but I’m not clear how to incorporate my (non-node) JavaScript into the test harness.
What I currently have is along the lines of:
myobj.js:
var MyObj = {};
MyObj.a = function() { return 'a'; }
MyObj.b = function() { return 'b'; }
myobj-sub.js:
MyObj.Sub = {};
MyObj.Sub.x = function() { return 'x'; }
MyObj.Sub.y = function() { return 'y'; }
These of course normally get pulled into the HTML using
<script src="myobj.js"></script>
<script src="myobj-sub.js"></script>
For the test harness, I guess I will need something like:
var test = require('tape');
test('myobj', function(assert) {
assert.equal('a', MyObj.a(), 'test a');
assert.equal('x', MyObj.Sub.x(), 'test x');
assert.end();
});
But I’m not sure where to fill in the gaps!
(ps: I’m running on Linux, if it makes any difference).
Thx.