Huge working in progress because I haven’t figured everything out yet.
Unit test is:
– fixed input
– expected a fixed output
Testing frameworks:
– Mocha
– Jasmine
Assertion libraries:
– Chai
//backend code //expect var expect = require('chai').expect; //example var _ = {}; if(typeof module !== 'undefined'){ module.exports = _; }
How to set up mocha:
#exe npm install -g mocha #local npm install chai mocha #put the following code in mocha.opts #mocha --reporter spec
The directory structure:
-test
–underbar.js
–mocha.opts
–index.html
-underbar.js
???not sure???
In browser:
var expect = chai.expect; mocha.setup('bdd'); mocha.run();
To test async code in mocha, use done()
//example it('should test async function', function(done){ setTimeout(function(){ done(); }, 500) })
Third party services:
– Travis-ci
– code-coverage, whether that particular line of code has been run in the test
– selenium
– browserling