I’m been delving more deeply into the world of front-end development recently, and after trying out a few different JavaScript unit testing tools I selected FireUnit. I installed the Firefox extensions Firebug and FireUnit – you need both for unit testing with FireUnit.
However, sometimes Firebug doesn’t work for me and I want to use Safari for debugging JavaScript. I also found some tests that worked in Firefox but failed in Safari just because of differences in how the browsers handle UTF-8. Running your JavaScript unit tests in multiple browsers is clearly a good idea. So, the obvious drawback to using FireUnit is that it only works in Firefox.
My solution is to create a stub version of FireUnit so when I run my tests in Safari, the stubs are defined, but when I run them in Firefox, my tests use the real FireUnit functions. The following code at the top of my test files make them work in any browser, with or without FireUnit.
<script src=”FireUnitStub.js” type=”text/javascript”></script>
Of course, I need my stub source code in a file FireUnitStub.js in the same directory for the above line to work.
I’ve only implemented a few of these functions so I hope someone else will do it properly and completely, maybe using the source code for FireUnit itself.
Hereby forthwith released into the public domain. Have fun!
Here’s a screen shot of my tests after a successful completion in the Safari browser, with the debugging enabled. (Click on the image to see the whole image.)


