ReSharper Web Help

QUnit is a powerful JavaScript testing framework. QUnit provides an opportunity to test any JavaScript code and ReSharper provides a way to do it quickly and effortlessly right from Visual Studio.

Consider the example below. The isEmail function checks whether a recently entered e-mail address is correct.

What if this function doesn't work properly? To find it out, use QUnit and its functions.

 Note

To use QUnit, you have to include qunit.js and qunit.css files.
In the example of a test below, test and ok functions are used. The first argument of the test function defines the name of the test. In our case it coincides with the name of the tested function. The second argument contains code to run and calls the ok function. So the test function checks whether correct e-mail address is treated as correct and whether incorrect e-mail address is treated as incorrect.

Click the gutter icon, then click Run. The test is run in a single session in the Unit Test Sessions window. As you can see the test has passed, so the function works properly.

When the tests are started, ReSharper launches the specified browser that runs the tests and reports the information back to ReSharper.

You can specify exactly what browser should be used. For more information, see Qunit.

See Also

Procedures

Reference