Recent Entries:

Favorite Links

jsUnit testing a method of a class with a boring constructor

Friday, August 29th, 2008

Today I wanted to introduce some jsUnit testing in an old class. In particular I wanted to test a single method in isolation but I could not instantiate the object itself since the constructor had dependency on other files.

The trick is to replace the object with a new one which has the same prototype but an empty constructor:

Leave a Reply