为什么Chutzpah只看到测试,如果他们列在“参考”部分下面,如果他们在“测试”下面则没有

时间:2016-09-24 23:15:25

标签: angularjs unit-testing jasmine chutzpah

我有一个很大的解决方案,有一些网络模块项目(它们是一种模块,它们被复制到一个共同的项目,即SPA)。我开始针对我的1.5.8代码编写jasmine-typescript测试。为了节省复制时间,我需要为每个Web项目设置Chutzpah,这样我就可以测试每个模块代码。

我有下面的chutzpah.json,这样当我选择“在浏览器中打开”然后我就能看到测试。

{
  "Framework": "jasmine",
  "FrameworkVersion": "2",
  "Compile": {"Mode": "External"},
  "References": [
    {
      "Path": "../../where_angular_and_other_scripts_are_placed/",
      "Includes": [ "*.js" ]
    },
    {
      "Path": "../../where_angular-mocks_are_placed/",
      "Includes": [ "*.js" ]
    },
    {
      "Path": "../../CommonLibrary/",
      "Includes": [ "*.js" ],
      "Excludes": [ "*.Spec.js" ]
    },
    {
      "Path": "app/modules/Framework/",
      "Includes": [ "*.Spec.js" ]
    }
  ]
}

如果我更改下面的文件,则没有测试。我不明白为什么。 Chutzpah无法管理解决方案在不同的目录中有多个chutzpah.json?根据文件,这应该不是问题。

{
  "Framework": "jasmine",
  "FrameworkVersion": "2",
  "Compile": {"Mode": "External"},
  "References": [
    {
      "Path": "../../where_angular_and_other_scripts_are_placed/",
      "Includes": [ "angular.js", "*.js" ]
    },
    {
      "Path": "../../where_angular-mocks_are_placed/",
      "Includes": [ "*.js" ]
    },
    {
      "Path": "../../CommonLibrary/",
      "Includes": [ "*.js" ],
      "Excludes": [ "*.Spec.js" ]
    }
  ],
  "Tests": [
    {
      "Path": "app/modules/Framework/",
      "Includes": [ "*.Spec.js" ]
    }
  ]
}

Chutzpah设置的另一个问题是,它总是说没有定义角度。我有下面的代码,当我运行它时,它表示没有定义角度。如果我移除了注射部件,那么它就会运行。但是,我需要嘲笑事情。我对上面的配置问题以及下面的东西以某种方式连接感到不好。

describe("getActiveModules method", (): void =>
            {
                var RestangularMock: any;
                var angularCommonCheckerService:AngularCommonCheckerService;
                var dilibModuleService: IDiLibModuleService;
                var $q: ng.IQService;
                var allReturnObject: any;

                beforeEach((): void =>
                {

                    //#region Arrange
                    angular.mock.inject(($injector): void => {
                        $q = $injector.get("$q");
                    });

                    RestangularMock = jasmine.createSpyObj("Restangular", ["all", "post"]);

                    angularCommonCheckerService = new AngularCommonCheckerService();
                    dilibModuleService = new DilibModuleService(RestangularMock, angularCommonCheckerService);

                    var returnList: IModuleContract[] = [
                        <IModuleContract>{ id: 100, isActive: 1 },
                        <IModuleContract>{ id: 101, isActive: 1 },
                    ];

                    var allReturnObject = <any>{
                        getList: (): IModuleContract[]> => {
                            var deferred = $q.defer();
                            deferred.resolve(returnList);
                            return deferred.promise;
                        }
                    };
                    spyOn(allReturnObject, "getList");
                    //#endregion

                });

                it("should call Restangular resource with given string", (): void =>
                {

                    RestangularMock.all.and.returnValue(allReturnObject);
                    dilibModuleService.getActiveModules();

                    expect(RestangularMock.all).toHaveBeenCalledWith("FrameworkApp/Module/GetActiveModules");
                    expect(allReturnObject.getList).toHaveBeenCalledTimes(1);

                });

问题

  • 为什么Chutzpah在“测试”下列出测试参考时没有列出测试?我做错了吗?
  • 注入问题是否与配置问题有关?
  • 我如何调试Chutzpah并查看参考和测试中包含的内容?它足以检查生成的html文件的来源吗?

0 个答案:

没有答案