4
votes

I am trying to get Chutzpah and Jasmine working together in visual studio, my end goal is to get unit tests running with TeamCity integration.

On save, all of the typescript code generates a single .js file. This also causes Chutzpah to run my tests, so far so good.

My issue is Chutzpah reports 0 passed, 0 failed and 0 errors. The Jasmine html file that is generated lists out all of my tests correctly but Chutzpa doesn't seem to receive any information back from Jasmine.

Highlights of a trace log:

Trying to build test context for c:\.....\test.ts
Building test context for c:\.....\test.ts
...framework dependencies / other ok looking things... (~15 lines)
Finished building test context for c:\.....\test.ts
Warning: 0 : Message:Chutzpah determined generated .js files are missing but the compile 
mode is External so Chutzpah can't compile them. Test results may be wrong.

Then it starts Phantom js and logs loading / receiving resources. My test.ts file is not one of the recources listed but the site-wide .js is (I checked the site-wide file and my tests are being appended to it).

Finished test run for c:\......\test.ts in Discovery mode
Cleaning up test context for c:\......\test.ts
Chutzpah run finished with 0 passed, 0 failed and 0 errors
Chutzpah.json file cache cleared
End Test Adapter Discover Tests

chutzpah.json

{
  "Framework": "jasmine",  
  "EnableTestFileBatching": true,
  "Compile": {
    "Mode": "External",
    "Extensions": [ ".ts" ],
    "ExtensionsWithNoOutput": [ ".d.ts" ],
    "Paths": [
      {
        "OutputPath": "../SiteWide.js",
        "SourcePath": "Views"
      }
    ]
  },
  "References": [
    {
      "Path": "../knockout-3.4.2.js",
      "IsTestFrameworkFile": true
    }
  ],
  "Tests": [
    {
      "Includes": [ "*.ts" ],
      "Path": "../Tests/Views"
    }
  ],
  "EnableTracing": true,
  "TraceFilePath": "./trace.log"
}

tests.ts

describe('configuring unit tests for typescript!', () => {
    it('this should pass', () => {
        expect(1).toBe(1);
    });

    it('this should fail', () => {
        expect(1).toBe(0);
    });
});

There are a few things I'm suspicious of (the missing .js files line from the trace - but that might just be caused by my single js file compilation step?)

Maybe I'm missing references to jasmine in my chutzpah.json?

I'm at a loss for why the Jasmine tests work, but Chutzpah doesn't report back.

1

1 Answers

1
votes

Maybe late... But something like this in chutzpah.json would help.

{
"Framework": "jasmine",
"Compile": {
    "Mode": "External",
    "Extensions": [ "*.ts" ],
    "ExtensionsWithNoOutput": [ "*.d.ts" ]
},
"References": [
    { "Path": "node_modules/promise-polyfill/dist", "Include": "*.js", "Exclude": "*.d.ts" },
    { "Path": "node_modules/systemjs/dist", "Include": "*.js", "Exclude": "*.d.ts" }
],
"Tests": [
    { "Path": "unittests", "Includes": [ "*.spec.ts" ], "Excludes": [ "*.d.ts" ], "ExpandReferenceComments": "true" }
]

}

Having your system related files is important in the references. Also you can try "*.spec.js" in the Tests section