Saturday, August 27, 2011

TDD In JavaScript: No Excuses

Madison RubyConf was awesome, but listening to the testing panel outraged me beyond words. I frothed at the mouth and nearly had an aneurysm right there in my chair. It sent me loony in the noggin and left me wondering how many guys on that panel were huffing glue right before they got on stage. Somebody said that testing was an insurance policy, and this madness went uncorrected - despite the fact that test-driven DESIGN is obviously about design - and when the subject of testing JavaScript came up, the consensus was NOT TO FREAKING DO IT.

Names will go un-named to protect the guilty, but I later cornered one of these lunatic miscreants on a rooftop while inebriated, and I have to give him credit, because the distinguished if utterly mistaken gentleman handled my vehement, drunken correction with grace and aplomb. So kudos there.

Nonetheless, if you're not writing your JavaScript TDD, you're out of your fucking mind. It's just so fucking EASY, and it's such a quirky language with so many pitfalls. Writing JavaScript without tests is like having sex without a condom, except worse, because it's the wiggiest language out there, and it can turn on you at any second, so it's more like having sex with a rabid orangutang without a condom during the act or a taser to subdue it afterwards so you can make your escape. Look, just write fucking tests when you write fucking JavaScript, OK? Seriously, what the fuck.

Here's a quick video showing how easy it is. The video uses CoffeeScript but everything in it translates very, very easily and directly into JavaScript; all you do is add punctuation. By the way, I wrote a lot of the code and the tests in this video while sitting in the audience of this testing talk. It's so easy you can do it without even fully paying attention to it because you're also busy listening to somebody tell you how allegedly impossible it is.

Aneurysms aside, Madison RubyConf really was one of the best conferences I've been to. I definitely recommend checking it out.

Update: Bryan Liles was on the testing panel, and he reminded me on Twitter that he did in fact say to test JavaScript.