Like most people, I like to run tests separately from production code.
If you use VS2012 (or later) and the Chutzpah test adapter , you can simply create a separate class library for your tests, as well as for your .NET code.
Add the tests.js` file to the test class library and simply reference the appropriate scripts from the main project. For example, using Jasmine and Angular:
/// <reference path="../../MainProject/lib/angular/angular.js" /> /// <reference path="../../MainProject/lib/angular/angular-mocks.js" /> /// <reference path="../../MainProject/lib/angular/angular-resource.js" /> /// <reference path="../../MainProject/lib/jasmine.js" /> /// <reference path="../../MainProject/scripts/controllers.js" /> describe('My controller tests', function () { ... });
If you want to avoid repeating all of these reference paths in each test js file, you can add them to the _references.js file, and then just specify only one script in your tests.js file. You will need to manually link to the file because you are not in a web project, and console projects do not have the same implicit links that web projects do.
source share