Click here to get a complete list of blogentries.

ImpUnit: A Small Open-Source Unit-Testing Framework in JavaScript

I have recently started to look into JavaScript more closely. I believe that it will be even more of a big thing in the near future than it is now. I have been using JavaScript for a long time now but as I now know I have never really gotten it right. After I read Douglas Crockford’s "JavaScript: The Good Parts" and "High Performance JavaScript" by Nicholas C. Zakas I had a much better understanding.

Anyway, one thing that has really helped me out many times is test-driven development. So, to make me feeling more comfortable while exploring the new depths of JavaScripts, I decided to create a little unit testing framework for me to use.

Try it yourself: Test the Test

Below you find an example class 'testMath' and a small suite testing it. Hit the 'Run Tests!' button to run the tests. You will then see, that 'testMath' is obviously faulty. Can you spot the error and correct it? Change the code and see how it affects the test results. You can run the tests as often as you like. You also have the permission to go crazy on it.

About The Project

It is a nice little side project that could be finished within hours and it's a great programming practice IMHO. I tried to follow all advice from Crockford's book and John Resig ( Best Practices in JavaScript Library Design - google techtalk). I managed to fit the whole framework into less than 100 lines of code without any external dependencies, all nicely wrapped in a local namespace. It compresses down to about 1kB!

Of course I also created a test suite that tests the framework, too. It works fine in

I don't expect any problems with most of the other browsers although I haven't checked. I'm going to do that in due time.

I release the code under a Apache 2 license and uploaded the project on github at

Fork Me On GitHub


The repository contains a complete documentation, How-To, API documentation and a small TODO list I plan to work off in the next days. Go check it out!

Posted on 2011/1/24
blog comments powered by Disqus
homecoded facebook logo
This is a picture of my address. I am not going to put that in plain writing!
Small print: