简体   繁体   中英

Testing TypeScript and AngularJS in Visual Studio with Jasmine and Chutzpah - can't find variable: angular

I'm trying to test my TypeScript and AngularJS code with Jasmine in Visual Studio Chutzpah. Test is running correctly in karma, but I realy like Chutzpah's UI.

My controllerSpecs.ts :

/// <chutzpah_reference path="../Scripts/angular.js" />
/// <chutzpah_reference path="../Scripts/angular-mocks.js" />
/// <chutzpah_reference path="../Scripts/angular-route.js" />
/// <chutzpah_reference path="../Scripts/angular-resource.js" />
/// <chutzpah_reference path="../Scripts/angular-local-storage.js" />
/// <chutzpah_reference path="../Controllers/MenuController.js" />
/// <chutzpah_reference path="../App/app.js" />
/// <chutzpah_reference path="../references.js" />
/// <reference path="../references.ts" />

describe('Controller Specs', () => {

describe('Menu Controller Specs', () => {
    var menuCtrl, scope;

    beforeEach(angular.mock.module('typewritingApp'));

    beforeEach(() => inject(($rootScope) => {

        scope = $rootScope.$new();
        menuCtrl = new App.MenuCtrl(scope);
    }));

    it('should be true', () => {
        expect(true).toBe(true);
    });
});

});

My app.ts :

module App {
var typewritingapp: ng.IModule = angular.module("typewritingApp", [])
    .controller("MenuCtrl", ["$scope", MenuCtrl])
}

My MenuController.ts :

module App {

export class MenuCtrl {
    constructor($scope: any) {
        $scope.pageTitle = "Menu";
    }
}
}

If I change the angular.mock.module part to module in the test (and I also need to modify the angular-mocks.d.ts to declare module) I receive the same error but it doesn't find variable: module.

I had a wrong karma config file and after it has started to work I forgot to update chutzpah.json so it was my fault. Thanks for the help @MatthewManela

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM