I would like to run unit tests of my JavaScript code in Cruise Control. We currently use nUnit, and I see that nUnit has a javascript library. How do I write unit (not UI) tests in JavaScript using nUnit?
I would like to run unit tests of my JavaScript code in Cruise Control. We currently use nUnit, and I see that nUnit has a javascript library. How do I write unit (not UI) tests in JavaScript using nUnit?
Share Improve this question edited Apr 27, 2015 at 20:57 George Stocker 57.9k29 gold badges181 silver badges238 bronze badges asked Jul 12, 2010 at 11:30 dehadeha 81511 silver badges30 bronze badges3 Answers
Reset to default 3The best way to automate JS tests and include them in continuous integration process is to use JSTestDriver. It is very fast, can test your scripts in all kinds of browsers, can be easily integrated in IDE (How To ntegrate JsTestDriver in Visual Studio), and what is more important - this is simple sole application, which can be easily be executed from nant script.
The example of solution with JsTestDriver tests is here.
You can do this with JSUnit. Their JSUnit Server allows you to run scriptable JavaScript unit tests within a Java virtual machine (JVM).
You can use Rhino, which is a Javascript runtime written in Java (IIRC, the mand-line is something like java -jar Rhino.jar script.js). This is especially useful if your tests don't require a browser.
Don't forget to analyze your JS code with JSLint !