mmanela / chutzpah

Chutzpah is an open source JavaScript test runner which enables you to run unit tests using QUnit, Jasmine, Mocha and TypeScript.
http://mmanela.github.io/chutzpah/
Apache License 2.0
550 stars 142 forks source link

References gets overwritten with the last one declared #832

Closed SylvainFI closed 8 months ago

SylvainFI commented 8 months ago

Hi,

I'm using Version: 4.3.3.0.

In chutzpath.json, I have:

{
  "Framework": "jasmine",
  "FrameworkVersion": "2",
  "RootReferencePathMode": "SettingsFileDirectory",
  "References": [
    { "Path": "../Scripts/angular.js" },
    { "Path": "../Scripts/angular-mocks.js" },
    { "Path": "../Scripts/services/app-constants.js" },
    { "Path": "../Scripts/services/fr/motor/app-constants.js" },
    { "Path": "../Scripts/services/en/motor/app-constants.js" },
    ...
   ]
}

Note that english app-constant is defined last.

../Scripts/services/app-constants.js

app.service("AppConstantsBase", function () {
    // common constants here
}

../Scripts/services/fr/app-constants.js

app.service('AppConstants', ['AppConstantsBase', function (appConstantsBase) {
  // french constants here
}

../Scripts/services/en/app-constants.js

app.service('AppConstants', ['AppConstantsBase', function (appConstantsBase) {
  // english constants here
}

In TestFrenchSpec.js

///<reference path="~/ref/fr/spec-references.js"/>
describe("FR", function() {
      beforeEach(function() {
      }
      it("should do something for french language", function() {
         // test with french constants
      }
}

In TestEnglishSpec.js

///<reference path="~/ref/en/spec-references.js"/>
describe("EN", function() {
      beforeEach(function() {
      }
      it("should do something for english language", function() {
         // test with english constants
      }
}

In "~/ref/fr/spec-references.js",


///<reference path="~/Scripts/jasmine/jasmine.js"/>
///<reference path="../../Scripts/angular.js"/>
///<reference path="../../Scripts/angular-mocks.js"/>

///<reference path="../../Scripts/services/app-constants.js"/>
///<reference path="../../Scripts/services/fr/app-constants.js"/>

When I run the tests, the French tests fail, because it has English constants instead of French ones... English tests work fine.

Thanks.

SylvainFI commented 8 months ago

ok I read the doc more thoroughly šŸ„‡ I now use multiple chutzpah.json files in subdirectories