Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chutzpah visual studio test runner cannot find JS references

I'm building an ASP.NET website in Visual Sutio 2013 and I'm testing with Jasmine and the Chutzpah test runner plugin. The tests are found alright, but the needed references are not loaded. I've tried starting my test file with the following to make sure the path is correct (and each version alone), but it still complaints that the angular value does not exist when I run the test. What am I missing?

/// <reference path="/Scripts/angular.js" />
/// <reference path="../Scripts/angular.js" />
/// <reference path="../../Scripts/angular.js" />
/// <reference path="../../../Scripts/angular.js" />
/// <reference path="../../../../Scripts/angular.js" />
/// <reference path="../../../../../Scripts/angular.js" />
/// <reference path="../../../../../../Scripts/angular.js" />
/// <reference path="../../../../../../../Scripts/angular.js" />
/// <reference path="../../../../../../../../Scripts/angular.js" />
/// <reference path="../../../../../../../../../Scripts/angular.js" />
/// <reference path="../../../../../../../../../../Scripts/angular.js" />
/// <reference path="../../../../../../../../../../../Scripts/angular.js" />

Even though this should have worked (as far as I understand), I also tried putting a chutzpah.json file in my project root with the following configuration:

"RootReferencePathMode":"SettingsFileDirectory"

and the following reference in the test file:

/// <reference path="/Scripts/angular.js" />

But this did nothing to help. Since Chutzpah does nothing to acknowledge the existence of the reference tag, I'm not even sure that has found it (though it obviously found the relevant test file).

like image 968
Morten Christiansen Avatar asked Oct 03 '22 11:10

Morten Christiansen


1 Answers

I'm not sure why it appeared that the angular reference was missing, but playing with the Chutzpah console as suggested by Matthew Manela made me realize that a lot of other references where missing for the test to complete successfully.

In the end, I ended up bundling all my references into a file called _references.js with the following content:

/// <reference path="jquery-1.9.1.js" />
/// <reference path="jquery-ui-1.8.20.js" />
/// <reference path="jquery.validate.js" />
/// <reference path="jquery.validate.unobtrusive.js" />
/// <reference path="knockout-2.1.0.debug.js" />
/// <reference path="modernizr-2.5.3.js" />
/// <reference path="angular.js" />
/// <reference path="jasmine/jasmine.js" />
/// <reference path="angular-mocks.js" />
/// <reference path="angular-route.js" />

/// <reference path="../Application/src/common/services/" />
/// <reference path="../Application/src/common/views/" />
/// <reference path="../Application/src/common/app.js" />

In my test I include the following reference:

/// <reference path="../../../../../Scripts/_references.js" />

The only remaining problem is that I have to figure out how many levels of nesting each test file has. My assumption was that I could put the following chutzpah.json file in my project root:

{
    "Framework": "jasmine",
    "RootReferencePathMode":"SettingsFileDirectory"
}

and then always use the reference:

/// <reference path="/Scripts/_references.js" />

This does not help, but maybe I'm misunderstanding how this is supposed to work.

like image 54
Morten Christiansen Avatar answered Oct 13 '22 11:10

Morten Christiansen