0

I have a quite big solution with a few web module projects (they are kind of modules and they are copied into a common project which is the SPA). I started to write jasmine-typescript tests against my angular 1.5.8 code. In order to spare copying time I need to set up Chutzpah for every web project so I can test every module code.

I have the chutzpah.json below and this way when I select "Open in Browser" then I can see the tests.

{
  "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" ]
    }
  ]
}

If I change the file like below then there are no tests. I don't understand why. Chutzpah cannot manage that a solution has more than one chutzpah.json in different directories? According to the documentation it shouldn't be problem.

{
  "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" ]
    }
  ]
}

Another issue with Chutzpah setup is that, it always says that angular is not defined. I have the code below and when I run it it says angular is not defined. If I remove the inject part then it runs. But, I need to mock things. I have the bad feeling the above configuration issue and the stuff below somehow connected.

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

                });

Questions:

  • Why Chutzpah doesn't list tests when the test references listed under "Test"? Did I do something wrong?
  • Is the issue around inject connected to the configuration issue?
  • how can I debug Chutzpah and see what is included from the references and tests? It is enough to check the source of the generated html file?
AndrasCsanyi
  • 3,943
  • 8
  • 45
  • 77
  • Chutzpah lets you turn on a tracing mode where it can log details of everything it looks for and finds (or doesn't find). When using the command line client you can turn this on with the /trace flag. – Matthew Manela Nov 25 '16 at 07:15
  • But if you are still having this issue and have a full repro I can take a look – Matthew Manela Nov 25 '16 at 07:16

0 Answers0