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

TypeScipt Javascript dependencies not being picked up in Chutzpah 4.2.0 #478

Closed bmacm closed 8 years ago

bmacm commented 8 years ago

This relates to the StackOverflow question over here. Logging here so to provide a Code Repo of the issue. ChutzpahRepo1.zip

I am using Angular 1.4.9 with Jasmine 2.2.0 and Chutzpah 4.2.0 with both my Angular code and unit tests in TypeScript in Visual Studio 2015 Update 1.

It appears that Chutzpah is not respecting reference javascript include in the Chutzpah.json file (namely angular in this case). When I run the tests via Chutzpah (context or VS test integration) the error states "can't find variable: Angular" and "can't find variable inject".

Running the test cases with Resharper (after some messing with the project structure as R# has it's own issues) results in the angular framework dependency being loaded and the correct angular error being thrown back (the controller is not known to Angular so to prove that angular is indeed loaded).

mmanela commented 8 years ago

A chutzpah.json like this should get you much closer. I still hit a different angular issue but should get you started:

{
  "Framework": "jasmine",
  "TestFileTimeout": 3000,

  "Compile": {
    "Mode": "External",
    "Extensions": [ ".ts" ],
    "ExtensionsWithNoOutput": [ ".d.ts" ]
  },
  "References": [
    { "Path": "scripts/angular.js" },
    { "Path": "scripts/angular-mocks.js" },
    { "Includes": [ "*/app/*.ts" ], "Excludes": ["*/app/*.d.ts"] }
  ],
  "Tests": [
    {
      "Includes": [ "*/Tests/*.ts" ],
      "Excludes": [ "*/Tests/*.d.ts" ]
    }
  ]
}

If you can figure out the rest given that please report back so I can see the final result

krvns commented 8 years ago

Hey, I had a lot of headache with this as well. A solution is to include to app.js ( not app.ts! ) as a reference in you chutzpah.json.

Then in should work just fine. So again, do this:

"References": [
    { "Path": "scripts/angular.js" },
    { "Path": "scripts/angular-mocks.js" },
    { "Includes": [ "*/app/*.js" ], "Excludes": ["*/app/*.d.ts"] }
  ], 

... and make sure your ts compiler is transpile .ts to .js before your test execution.