Search code examples
unit-testingtypescriptjasminechutzpah

Why Chutzpah does not recognize all TypeScript tests?


I have a project with the following chutzpah.json:

{
  "Framework": "jasmine",
  "TestHarnessReferenceMode": "AMD",
  "TestHarnessLocationMode": "SettingsFileAdjacent",
  "EnableTestFileBatching": true,

  "References": [
    { "Path": "node_modules/es6-shim/es6-shim.min.js" },
    { "Path": "node_modules/zone.js/dist/zone.min.js" },
    { "Path": "node_modules/reflect-metadata/Reflect.js" },
    { "Path": "node_modules/systemjs/dist/system.js" },
    { "Path": "system-config.js" }
  ],
  "CodeCoverageExcludes": ["node_modules/*"],
  "Tests": [
    { "Path": "app", "Includes": [ "*.spec.ts" ] }
  ]
}

and the following tests files

2016-08-05_13-54-34

Test explorer just shows tests stored in the first file 2016-08-05_13-56-33

If I try to run the the command of the VSTest I get the same result: 2016-08-05_13-57-21

If I call the command setting the name of the file (e.g. "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" app\InspectionDataView.spec.ts /UseVsixExtensions:true ), the tests in the file run.

Extra point:

I tried to run the test directly with Chutzpah.console.exe, this is what I got:

2016-08-05_14-05-58

What am I missing here ?

Note: Using VS 2015 Update 3


Solution

  • Chutzpah does not run TypeScript. It "supports" it, but you have to add this support in the chutzpah.json.

    Why the first test suite succeeds? Perhaps it is written in pure ES5 (Without ES6/TS classes, interfaces, etc).

    I did set up chutzpah support for typescript from this repo https://github.com/mmanela/chutzpah/tree/master/Samples/Compilation/TypeScript

    Basically, in short:

    1. create a compile.bat that transpiles TS to ES5. Normally - tsc.exe with or without tsconfig.json
    2. add "Compile" section as seen in https://github.com/mmanela/chutzpah/blob/master/Samples/Compilation/TypeScript/chutzpah.json

    this shall transpile TS to ES5 every time you run chutzpah.console.exe