UnRegister: JavaScript, CoffeeScript and UI Testing

I’ve been thinking about the UI lately for UnRegister and this means some client-side code, vis-a-vis JavaScript. My plan was to dive right in, but then I read this post. Now that got me thinking. So what do I think? I think I’ll leave CoffeeScript alone.

Translator Please

The folks over at say that “CoffeeScript is a little language that compiles into JavaScript.” Well how delightful. I’m a tremendous fan of the .Net framework. I’ve looked around at other programming languages but as a general rule, for the majority of my projects, I tend to return to the .Net framework for my programming needs. Yeah, it helps that I’m more comfortable working with it than any other framework, but it also does a great job. At its heart is this thing called the CLR, and that is responsible for compiling your VB.Net or C# code into machine language. Wouldn’t it suck some serious ass if we had to write that out directly (unless of course you’re into that sort of thing!!).

So can we draw parallels between what the CLR is doing for us and CoffeeScript? Not a damn chance.

To me writing something out in CoffeeScript and “compiling” it into JavaScript isn’t providing enough of a benefit for me to consider it useful, and not at all necessary. Now I admit, I haven’t used CoffeeScript, but that’s because I don’t want to. To me it’s a little like using a translator to facilitate communications between somebody that speaks North Carolinian English and someone that speaks Californian English. In Rob’s post, linked to above, he links to this article which you really drives home some good points and identifies some of what my initial reservations were. You mean to say you want to write something in CoffeeScript, compile it down, consume the outputted JavaScript, run into an error, not have a clue what that error means, have no debug tools available to you, and have to track that back down in CoffeeScript somehow? It sounds like what one tremendous step backwards would feel like if you were standing with your back to the Grand Canyon two feet away from the ledge. Maybe there is some magic pixie dust (STOP! Is there such a thing as non-magical pixie dust???) that someone will sprinkle on you that gives you wings and allows you to soar above me with all the other CoffeeScript adopters. I sure hope I don’t miss out on that.

JavaScript Unit Tests

I’m sorry, what did you say? Man, I’ve been standing in opposition of unit testing for years now, only to finally have been won over by its benefits, but I have limits! Hopefully somebody is out there reading this and will tell me what an idiot I am, please feel free. In the meantime I’m going to sneeze a handful of good old fashioned man powered testing back at ya. Okay, I’ll concede that for those of you developing for node.js, backbone.js, or who knows whatever popular server-side JavaScript platform is popular at the moment that you probably really do need to unit test your JavaScript. For those of us using it to spice up our ASP.Net MVC driven sites, or RoR, PHP, or whatever, I don’t get it. NOT AT ALL!

How about a scenario. Okay. I have a site. I want customers to be able to register for my site. I want them to give me an email address, password, confirmation password, name of their first born, if they don’t have a first born than the name of their absolute favorite Star Wars character, and how about a date of birth for good measure. Now I’ll have server side validation, and not driven by the damn database thank you very much, but I’m also expecting millions of new users to register every second, so what am I going to do??? I’ll be responsible and add in some client-side validation of course, and I’ll feel damn good about myself for doing it. I’m not going to reinvent the wheel so I’m going to leverage the JQuery Validation plug-in (go find it, it really exists), and drop in my validation rules. After all that I’m going to expect when somebody tests my site they know about that little spinny thing that starts its spinning, and that it does this when the browser makes the request of the server. So when they see failed validation when they click on the register button, and they don’t see the little spinny thing, they will know that some client-side validation fired.

But seriously … (man I’m exhausting myself) … is there really a need? I’m thinking that for 95% of the JavaScript code out there we don’t need to be concerned with writing unit tests for.

UI Testing in UnRegister

I’m very sad to say that at the very least I will not be doing this up front. I really do want to to try out something like WaitiN, but that will come at the end of the project, time permitting. If you’ve used any other tools, please recommend them.