【问题标题】:Testing TypeScript and AngularJS in Visual Studio with Jasmine and Chutzpah - can't find variable: angular使用 Jasmine 和 Chutzpah 在 Visual Studio 中测试 TypeScript 和 AngularJS - 找不到变量:角度
【发布时间】:2015-12-27 22:06:33
【问题描述】:

我正在尝试在 Visual Studio Chutzpah 中使用 Jasmine 测试我的 TypeScript 和 AngularJS 代码。测试在 karma 中运行正常,但我真的很喜欢 Chutzpah 的 UI。

我的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);
    });
});

});

我的app.ts

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

我的MenuController.ts

module App {

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

如果我在测试中将angular.mock.module 部分更改为module(并且我还需要修改 angular-mocks.d.ts 来声明模块)我会收到相同的错误,但它没有找到变量:模块。

【问题讨论】:

  • 您使用的是 chutzpah.json 文件吗?它是否引用了一组与您的 karma.conf 类似的文件?
  • 啊,谢谢。我有一个错误的业力配置文件,我忘记更新 chutzpah.json...非常感谢。
  • @bucicimaci 您应该为您赢得的问题发布答案,以便可以关闭此问题并在将来帮助其他人。

标签: angularjs visual-studio visual-studio-2013 typescript chutzpah


【解决方案1】:

我有一个错误的业力配置文件,在它开始工作后我忘记更新 chutzpah.json 所以这是我的错。感谢@MatthewManela 的帮助

【讨论】:

    猜你喜欢
    • 2016-05-28
    • 1970-01-01
    • 2013-02-22
    • 2016-07-18
    • 2016-08-05
    • 2017-06-21
    • 2016-12-03
    • 2013-08-25
    • 1970-01-01
    相关资源
    最近更新 更多