Examining the script.aclo.us Unit Testing Implementation

Introduction


This article walks the brave reader through the guts of the unit testing code provided by script.aculo.us, (hereafter referred to simply “scriptaculous”, because that’s hard enough to type as it is) the JavaScript library that powers most of those nifty interactive and Ajaxy effects you’re enjoying on web sites these days.

This exegetical exercise sprang from my own personal desire to understand scriptaculous’ unit testing implementation in order to evaluate its potential for providing unit testing for a project of my own. The unittest.js file is examined, and in particular I take a very close look at Test.Unit.Runner. The details that follow would hopefully explain to interested parties how this code works, but it also, I think, serves as an elucidation of a lot of interesting topics in JavaScript: prototype-based object-orientation, constructors, JSON-like syntax, closures, and mixins, just to name a few.

And, also, the scriptaculous documentation is not quite complete, so this little exercise might provide some material for improvements in that regard.

As always, I would LOVE feedback. Please email me at mh (that’s.me) at this domain, and include something in the title like script.aculo.us, so I can easily pick you email out from spam. Although you never know, some spam camouflages itself eerily well.

So, if you’re ready to dive in…

Next: Tackling the Code

Or, you might want to skip right to the implementation of actual tests.