Search code examples
visual-studiounit-testingtypescriptjasminechutzpah

How to setup a Jasmine / Chutzpah unit tests project running TypeScript files?


I have tried setting up a unit-tests project to cover front-end code in TypeScript with Jasmine and Chutzpah, but have a hard time figuring out what I'm doing wrong.

I have created a sample ASP.NET projet in which I have extracted and included the default jasmine tests. Pressing F5 opens a browser and makes the tests pass.

I have then converted all the tests to TypeScript and included its definitely typed definitions. Pressing F5 opens a browser and makes the tests pass.

enter image description here

I have finally installed Chutzpah with its Visual Studio extension, but I'm not able to either make the tests pass using the Visual Studio/Resharper Unit Tests window or the default chutzpah console. At this stage, pressing F5 still opens a browser and makes the tests pass.

enter image description here

That's the last step I'm struggling with. For clarity of the discussion, I have setup a sample projet on GitHub to reproduce my problem. I'm sure it must be something really simple but I just cannnot figure it out.

The project can be found at the following location: https://github.com/springcomp/TypeScript.Jasmine.Chutzpah.Sample


Solution

  • This doesn't really answer the 'Why', I'm still trying to get my head round this myself. However it might get you a bit further forward..

    I saw the same behavior when I pulled down your project. If I put the below reference paths in at the top of the PlayerSpec.ts :

    ///<reference path="../src/Player.ts"/>
    ///<reference path="../src/Song.ts"/>
    ///<reference path="../spec/SpecHelper.ts"/>
    ///<reference path="../Scripts/typings/jasmine/jasmine.d.ts"/>
    

    After this Resharper runs the tests successfully with them passing.

    I can't explain why - maybe resharper doesn't use the SpecRunner file for picking up references?