Unit testing front-end JavaScript presents its own unique set of challenges. Yesterday we had another event in the Test Driven Developers Bay Area meetup group. At this event I presented a number of different techniques to tackle these challenges and make our JavaScript unit tests fast and robust using Jasmine (another version using QUnit). I covered the following subjects:

  • Mocking and spy techniques to avoid dependencies on
    • Functions, methods and constructor functions
    • Time (new Date())
    • Timers (setTimeout, setInterval)
    • Ajax requests
    • The DOM
    • Events
  • Expressive matchers
    • jasmine-jquery
  • Structuring tests for reuse and readability
  • Testing browser-specific behaviour

You can watch the 1:30 hour video, just hear the audio (better sound), look at the code and watch the slides:

Leave a Reply

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