There is a Javascript unit testing framework here: http://www.edwardh.com/jsunit/ I never actually tried it though.
CategoryTesting TestingFramework