Unit Test in Visual Studio?

Topics: General
Jul 4, 2013 at 12:20 AM
Is there some built-in way to test TypeScript files and show results on Test Explorer? If not, any plans to add it?

And what could I use today to do that, using TypeScript 0.9.0.1 and Generics?
Jul 4, 2013 at 9:08 AM
Chutzpah works with QUnit and Jasmine tests written in TypeScript. Find it in the extension manager, there's a Test Runner and a Test Adapter, you want the latter.

HTH.

Mark

On Thursday, July 4, 2013, brunolm7 wrote:

From: brunolm7

Is there some built-in way to test TypeScript files and show results on Test Explorer? If not, any plans to add it?

And what could I use today to do that, using TypeScript 0.9.0.1 and Generics?

Read the full discussion online.

To add a post to this discussion, reply to this email ([email removed])

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com



--
Mark Rendle
Founder & CEO
Oort Corporation
Makers of Zudio

Jul 4, 2013 at 5:30 PM
Unfortunately that doesn't work with Generics. I hope they release an update.

Example:

linq.ts
module TSLinq
{
    export class Linq
    {
        constructor(private a:any[] = [])
        {
            Object.defineProperty(this, "a", { value: a, writable: false });
        }

        Aggregate(selector: (previousValue: any, currentValue: any, currentIndex?: number, array?: any[]) => any, initialValue?: any): any
        {
            return this.a.reduce(selector);
        }
    }
}

interface Array
{
    AsLinq(): TSLinq.Linq;
}
Array.prototype.AsLinq = function(): TSLinq.Linq
{
    return new TSLinq.Linq(this);
}
linq.ts (generics)
module TSLinq
{
    export class Linq<T>
    {
        constructor(private a: T[] = [])
        {
            Object.defineProperty(this, "a", { value: a, writable: false });
        }

        Aggregate<TResult>(selector: (previousValue: T, currentValue: T, currentIndex?: number, array?: T[]) => TResult, initialValue?: T): T
        {
            return this.a.reduce(selector);
        }
    }
}

interface Array
{
    AsLinq<T>(): TSLinq.Linq<T>;
}
Array.prototype.AsLinq = function<T>(): TSLinq.Linq<T>
{
    return new TSLinq.Linq<T>(this);
}
linq.test.ts
/// <reference path="qunit.d.ts" />
/// <reference path="linq.ts" />

test("Aggregate", () =>
{
    var result: number;
    
    result = [3, 1, 2].AsLinq().Aggregate((a, b) => a + b);

    equal(16, 16);
});
With the non generic code the test works, when I use generics it crashes at
linq.ts (3,23): Expected '{'
Oct 4, 2013 at 3:32 AM
I just tried this with the latest release of Chutzpah and the generic version worked fine. That said, there is an outstanding bug with the latest Chutzpah; hopefully this will be fixed soon.