views:

222

answers:

5

I'm looking for a javascript unit test framework that I can use as part of my automated maven build. This CANNOT use an actual browser, and it MUST be fully browserless.

I've tried looking at a few posts on SO, but none seem to meet my needs. Is there such a javascript unit tester? I'm anxious to find out.

+1  A: 

Not sure about a JavaScript unit testing framework, though I'm sure there is one. But I would probably look towards Rhino as JS interpreter.

http://www.mozilla.org/rhino/

If your JS references any of the browser/DOM you'll also need to mock/stub those...

ptomli
A: 

AFAIK, javascript is a language specifically designed to run in the browser.

Have you considereds j-unit tests? They do still run in the browser however.

Joshua
JavaScript started life in a browser, but is emphatically *not* a browser-only language. Within just a couple of years of its inception it was being used in non-browser environments, and continues to be. Its specification[1] is general, not browser-specific. It's a scripting language in any number of software packages, a server-side language for dynamic web sites, a command shell scripting language, etc., etc.[1] http://www.ecma-international.org/publications/standards/Ecma-262.htm
T.J. Crowder
A: 

Have you tried JSunit?

Does it not require a browser?
Stefan Kendall
+2  A: 

There are two projects called JSUnit (www.jsunit.net) and (jsunit.berlios.de). The latter is designed to work with Rhino and Maven. Note that there will be browser-specific problems that such tests will not discover, but it should help with basic functionality.

Kathy Van Stone
+1  A: 

I was trying to solve the same problem. It seems, that this is not as common, as one might think from our perspective.

RhinoUnit looks very good.

If you need browser capabilities within Rhino, take a look at

GrGr