JsTester is a library to run javascript tests from within .NET by using phantom.js instead of a UI browser.

Blog Posts


Currently, jasmine.js is the only javascript test framework supported. Tests can be run using any .NET framework and/or runner, but full integration support is only available for xUnit .


Phantomjs.exe needs to be available in the path.


1. Prepare the jasmine spec file

Edit the jasmine runner.html file and add a conditional to only execute the tests on load if running on a UI browser. For example:

    <title>Jasmine Test Runner</title>
    <!-- Additional resources -->
     <script type="text/javascript">
         jasmine.getEnv().addReporter(new jasmine.TrivialReporter());

         if (navigator.userAgent.indexOf('PhantomJS') == -1) {

2. Invoke the test from .NET

If you are using xUnit you can use the RunWithPhantomjs and JasmineSpec attributes to point to the jasmine spec file. By default, the name of the spec file is inferred from the method name, but it can also be supplied to the JasmineSpec attribute.

  using JsTester.Xunit;
  namespace Tests.Integration
      public class MyJasmineTests
          public void TestRunner()

Now you can execute this test as part of the regular xUnit run.