CodeMash 2013 Precompiler Day 2, Session Two

CodeMash

This afternoon’s session is Real-world JavaScript Testing with Justin Searls. This is supposed to be fairly hands on so I apologize if my notes aren’t very good since I will be focusing on doing. 🙂

We will be using a tool that TestDouble (the presenter’s company) built called lineman. It will run tests upon the file being saved. The test framework we are using is Jasmine, which has it’s roots in RSpec. QUnit is also a reasonable alternative.

Jasmine has spies, which are test doubles. Invoked by calling spyOn(<object>, <methodname>) – so, spyOn(loading, ‘show’).

Inject HTML into your tests with jasmine-fixture to avoid your testing being too reliant on the DOM.

You can use JSLint or JSHint to do static analysis of your JavaScript. CoffeeScript code is guaranteed to pass JSLint.

jasmine-given gives you a given-when-then syntax for your tests which many people consider more readable and intuitive.

And then we started pairing and writing some code and tests. Good stuff!

Advertisement