Using Chutzpah to run Typescript qUnit tests

拥有回忆 提交于 2019-12-05 17:27:02

I was able to get your example working with the following definitions for your test file and code file. I placed all files in the same directory but you can easily move them and change the paths.

TreeBurst.tests.ts

///<reference path="qunit.d.ts" />
///<reference path="TreeBurst.ts" />

module DMC.TreeBurst {

QUnit.module("TreeBurst.Node.ts tests");

test("Load-a-single-node-creates-correctly", () => {

    var node = [new DMC.TreeBurst.Node({
        id: 1,
        parentId: null,
        title: ""
    })];

    ok(node, "Node not created correctly when provided valid constructor parameters");

});
}

TreeBurst.ts

module DMC.TreeBurst {

export interface NodeOptions {

    // location specific
    id: number;
    parentId?: number;

    // node internals
    title: string;
    content?: string;
    colour?: string;        
}

export class Node {

    public id: number;
    public parentId: number = null;
    public title: string;
    public content: string = null;        
    public depth: number = null;

    public colour: string = null;

    constructor(opts: NodeOptions) {
        //removed from brevity
    }
    // methods removed for brevity
}
}

Adding a reference to a js file has no effect. Also instead of referencing reference.ts reference the folder http://matthewmanela.com/blog/chutzpah-2-2-with-typescript-support/ this is because of the way chutzpah works (does not compile referred files with --out)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!