Search code examples
visual-studio-2013typescriptjasminechutzpah

TypeScript + Chutzpah + Jasmine - How to include dependencies in unit test?


I'm running Visual Studio 13 with the Chutzpah test runner and the Jasmine-library. I want to test class A which has dependencies to class B. Class A also has dependencies to JQuery so my code looks something like this:

/// <reference path="../typings/jquery/jquery.d.ts"/>
/// <reference path="../B.ts"/>

describe("A", () => {
    it("can be instaniated", () => {
        var instance = new A();
    });
});

But I'm getting error when I run the test-runner that says: Error: ReferenceError: Can't find variable: $ So it seems like the test-runner cannot resolve the typing include for JQuery?

I have tried to add the following code:

/// <reference path="../jquery-2.1.1.js"/>

But then the compiler complains about that only ".ts" files are valid?! So what am I missing here? I thought that it was OK to include JS-files in TS-files? And how come I need -blocks in the Jasmine-tests but not anywhere else in the application (the compiler resolves the dependencies automatically)?

Is there a "standard way" of resolving dependencies when running Chutzpah + Jasmine in TypeScript?


Solution

  • The standard solution was to use the chutzpah.json-config that comes with Chuzpah, now the dependecies work like a charm! https://chutzpah.codeplex.com/wikipage?title=Chutzpah.json%20Settings%20File