How to make unit test JavaScript using nUnit?

I would like to run unit tests of my JavaScript code in Cruise Control. We are currently using nUnit, and I can see that nUnit has a javascript library. How can I write non-UI tests in JavaScript using nUnit?

+4
source share
3 answers

The best way to automate JS tests and incorporate them into the continuous integration process is to use JSTestDriver . It is very fast, you can test your scripts in all browsers, can be easily integrated into the IDE ( How to Link JsTestDriver in Visual Studio ), and more importantly, it is a simple console application that can be easily executed from a nant script.

An example solution with JsTestDriver tests is here .

+3
source

You can do this with JSUnit . Their JSUnit server allows you to run scripts for JavaScript scripts in the Java Virtual Machine (JVM).

+1
source

You can use Rhino, which is a Javascript runtime written in Java (IIRC, the command line has something like java -jar Rhino.jar script.js). This is especially useful if your tests do not require a browser.

Remember to parse your JS code with JSLint!

0
source

Source: https://habr.com/ru/post/1315395/


All Articles