Codemash 2013 – Testable Javascript

presenter James Kovac  JetBrains

4:50 PM 1/10/2013 Salon D

First reviewed the history of javascript.

  • First browser was lynx, all text no javascript
  • First browser with javascript was Netscape version .9.  Had it’s own javascript named livescript
  • Microsoft came out with it’s own version with DHTML to support Outlook web clients
There are now many complex javascript libraries and javascript code has been become very complex.  Because of this need to test just like we do with our server based code.  The tools he will review help bring Red-Green-Refactor motif to javascript.
Reviewed the following testing platforms
  • Qunit – built by jQuery to automate their testing
  • Jasmine
  • Mocha, with Chai
Jasmine with jQuery plug in very effective for testing jQuery.  Qunit very familiar for traditional TDD approach, Jasmine Mocha more BDD based.   Mocha is based on node.js therefore do not need a browser to run it, can run it through node.js.
Downside to all except Mocha is asynch testing.  Since Qunit and Jasmine rely on browser there is need for boiler plate code to write ansyced tests.  Mocha much better with asnyc since node.js based.
Synon.js is a mocking library for javascript.  Phantom.js is a headless browser for windows and perhaps could be used to automate tests for Qunit or Jasmine.

Leave a Reply

Your email address will not be published. Required fields are marked *