5

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).

Morten Christiansen
  • 19,002
  • 22
  • 69
  • 94
  • Can you show us what one of your tests looks like? – Simon Adcock Nov 14 '13 at 12:19
  • The test itself should hardly be relevant, since it fails at the first object that it expects to be defined (missing the `angular` object): `beforeEach(angular.mock.module('Application'));` – Morten Christiansen Nov 14 '13 at 13:25
  • You've included a reference to Jasmine, I'm guessing? Something like `/// `. And Chutzpah hasn't complained that `beforeEach` isn't defined, for instance? It would be weird if Chutzpah could find your Jasmine file, but not Angular... – Simon Adcock Nov 14 '13 at 17:47
  • 4
    If you run chutzpah from the command line you can specify the /trace command. This will output a file which shows what files Chutzpah found. – Matthew Manela Nov 14 '13 at 19:50
  • Also, You can file a bug on chutzpah.codeplex.com and attach a zip containing a repro of your issue – Matthew Manela Nov 14 '13 at 19:51
  • @SimonAdcock I hadn't actually given that any thought. I haven't added a reference to Jasmine in my test file, and I guess I just assumed that Chutzpah knew about Jasmine. – Morten Christiansen Nov 15 '13 at 09:06

1 Answers1

4

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.

Morten Christiansen
  • 19,002
  • 22
  • 69
  • 94