ReSharper Web Help

There are two powerful JavaScript testing frameworks: QUnit and Jasmine. Using them you can test any JavaScript code. Using ReSharper you can 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, you can use QUnit or Jasmine and write a test.


To use QUnit, you should reference qunit.js and qunit.css files. For more information, see QUnit Web site.
To use Jasmine, you should reference jasmine.js and jasmine.css files. For more information, see Jasmine Web site.


Since ReSharper 7.1 nested references are supported, so you do not have to reference framework files directly from your files with tests.
In the example below, test and ok functions from QUnit 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 of 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.

You can write the same test using describe, expect and it functions from Jasmine.

ReSharper detects tests automatically. 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.

Optionally, you can set settings so, that tests are run with PhantomJS library without launching a browser. For more information, see JavaScript Tests.

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

See Also