Chutzpah 2.2 with TypeScript support

This release contains a few new features most notably that Chutzpah can now work directly on TypeScript files. You can get the new bits from CodePlex, NuGet or go to the Visual Studio Gallery to get the updated Visual Studio Context Menu Extension  and Unit Test Explorer adapter for Visual Studio 2012.

Changes

  • Added support for writing tests in TypeScript (item 67
  • Fixed encoding problem with .coffee files (item 63)
  • Allow reference paths for folders (item 68)
  • Some Unit Test Explorer bug fixes
  • Added clearer error messages when test file does not exist

TypeScript Support

Chutzpah now supports running unit tests you write in TypeScript. Chutzpah will automatically generate temporary JavaScript files for your referenced TypeScript files and use those to gather the test results.
For example given a TypeScript test file that references another TypeScript file:

/// <reference path="../code/code.ts" />

test("will add 5 to number", function () {
    var res:number = mathLib.add5(10);

    equal(res, 15, "should add 5");
});

It will parse that file as well as the referenced code.ts files and generate corresponding .js files.

If you are writing QUnit tests be aware that you need to write QUnit.module instead of just module since module is a reserved word in TypeScript.

Referencing Folders

In your test files you can now reference folders using the reference declarations. For example when Chutzpah sees this line:

/// <reference path="../someFolder/" />

It will traverse that folder and add the files in it as references. This can be easier to manage than referencing many files individually.

This entry was posted in Chutzpah, TypeScript. Bookmark the permalink.

16 Responses to Chutzpah 2.2 with TypeScript support

  1. Pingback: The Morning Brew - Chris Alcock » The Morning Brew #1219

  2. Sean says:

    Awesome stuff.
    One issue we have while running the console exe against a folder containing jasmine specs, is that chutzpah will execute the .ts file and then the generated .js and .min.js files. Is there a way to switch off this behavior ?

    • Matthew says:

      Are these the generated .js files that Chutzpah creates or that a different tool generates?

      • Sean says:

        Oh boy do I feel silly now! Your right. It’s our compile step!

      • Matthew says:

        I still think Chutzpah so avoid those files if you know you only want to run .ts files. Chutzpah is able to do this inside of Visual Studio but I have not exposed this functionality to the command line client. I will look at adding this soon.

  3. David says:

    First, I am impressed with your project, and want to make it part of our team’s standard tool set.

    I do have a problem, and I think you had a brief exchange with someone about it on your site some time ago. It concerns jasmine-jquery and test fixtures. I posted a detailed explanation on stack overflow: http://stackoverflow.com/questions/13769066/unable-to-get-jasmine-jquery-fixtures-to-load-in-visual-studio-with-chutzpah-or

    I could use a bit of help with this. Also, of slightly less importance, I was unable to get the VS2010 test runner to actually run the tests. The menu item doesn’t appear to trigger anything. In VS2012, it works like a charm.

    Thank you,
    David

  4. Chris says:

    First off–awesome extension. Been very impressed so far. However, I’m running into an issue. There seems to currently be a bug with registering with codeplex so I’m posting the issue here instead…

    The temp typescript file Chutzpah generates seems to be wrong when doing simple inheritance (v 2.2.1). For example:

    MyClass.ts


    ///
    class MyClass extends MySuperClass {
    }

    MySuperClass.ts


    class MySuperClass {
    constructor (public message: string) { }
    }

    MyClassTest.ts


    ///
    ///
    test("inheritance working?", function () {
    var message = "a message";
    var myc = new MyClass(message);
    equal(myc.message, message, "message should get passed through");
    });

    when running the test in VS 2012 or the browser, I get the following error:


    Uncaught ReferenceError: __extends is not defined

    It’s because the generated file doesn’t have the __extends function. tsc creates it, just not Chutzpah. I’m wondering if the internal compiler of Chutzpah needs to be updated to use the latest tsc?

  5. Derik says:

    Both the nuget and the codeplex site only have 2.1, not the 2.2 version which supports typescript. Am I missing something?

  6. Abigail says:

    I’m so excited that this works with TypeScript! It was slick as a whistle. :) I’m still hoping for an update that will do the /// <reference trick with the command line client (it works great in VS, but from the command line we still need a fake test harness).

  7. Ben Kotvis says:

    Has anyone created a Typescript definition file for this? When I try to use it typescript doesn’t recognize any of the methods.

  8. jpt says:

    When I run tests, I’m getting Typescript errors that appear to indicate that my scripts are being compiled with TypeScript 0.9. My Visual Studio dev environment is configured to run under TypeScript 0.8.x. Is Chutzpah using some embedded TS interpreter or something? I can’t figure out how this is happening.

    Here’s an example of the errors I’m seeing:

    C:\longpath\Source\Client.Web\Scripts\ts\jquery\jquery.d.ts: error TS2172: All named properties must be subtypes of string indexer type ‘HTMLElement’:
    Type ‘(handler: any) => JQuery’ is missing property ‘ondragend’ from type ‘HTMLElement’.
    C:\longpath\Source\Client.Web\Scripts\ts\jquery\jquery.d.ts: error TS2172: All named properties must be subtypes of string indexer type ‘HTMLElement’:
    Type ‘(handler: (event: any, jqXHR: any, settings: any, exception: any) => any) => JQuery’ is missing property ‘ondragend’ from type ‘HTMLElement’.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>