Test-Driven JavaScript … Today.

I came across a kickstarter recently, “Let’s Code: Test Driven JavaScript.” It looks like a great project from James Shore, but for those who want to play with TDD and JavaScript today, there are quite a few resources out there.


Hold up, what’s TDD?
TDD stands for Test-Driven Development. The idea is that instead of writing code and figuring out how to test it later, why not write the test first and work backwards? You may have also heard of BDD — Behavior-Driven Development. There’s little difference besides the conceptual approach. In TDD, you write tests first and make them pass, in BDD, you describe behaviors and then make them pass.


Okay, I’m good. Now talk to me about this JavaScript stuff
Thanks to the glorious event that is BarCamp Philly, I heard about JavaScript testing frameworks some years ago (thanks, smart people!). There are a couple quite good ones, notably Mocha (TDD) and Jasmine (BDD). Rebecca Murphey has a dandy screencast showing how to use Jasmine to test jQuery, complete with example code.


More! More!
Okay! So the general issue with saying “here’s a tool! neat!” is that it leads to wondering how the heck you’re going to use it. So I was excited to see Murphey’s js-assessment repo, which reminds me of the Ruby Koans, except without the Zen, and also more beginner friendly, since its dependence on the command-line is far less than the Koans (unless you do them in the browser, but then there’s no saving). js-assessment uses Mocha for testing, and a few other dependencies of things I’ve personally wanted to check out. Note, the command line test support was a little wonky when I tried to use it, but a beauty of JS is that one just needs to refresh the test page to see new results.


Give it a try!
I’m interested to see the results of Shore’s project (19 days to fund!) once I’ve worked through js-assessment (and pondered making my own koans-style version …). I’m perhaps more interested to hear what kinds of JS testing and TDD you all have been doing!
Be Sociable, Share!

Tags: ,

2 Responses to “Test-Driven JavaScript … Today.”

  1. maudeline-auguste May 23, 2012 at 5:00 pm #

    HiI would like to participate in this training, how can I proceed if I’m out of USA?Kinds Regards

  2. Pam Selle May 23, 2012 at 7:59 pm #

    Maudeline, I’m not sure if you’re talking about the kickstarter, and I’m not sure about their policy for international contributors. However, I bet Shore will sell the end product internationally.

Leave a Reply