我最近尝试将qUnit和Chutzpah合并到单元测试我正在编写的打印在脚本中的项目。使用Chutzpah运行Typescript qUnit测试
我有事情在安装,我相信什么是正确的方式和下面的工作的事情:
- 的打字稿应用! - 我可以运行应用程序
- 放肆的一个非常早期版本 - 我将它安装在VS2012,它正确地看到的我qUnit演示试验
- qUnit - 出现安装和放肆的作品,我可以运行一个简单的测试(其中一个不看我的代码)
有了这三个到位我认为我可能会开始写的打字稿应用测试,测试我写的打字稿一个简单的测试:
TreeBurst。 Tests.ts
///<reference path="../typings/qunit/qunit.d.ts" />
///<reference path="references.ts">
///<reference path="references.js"> // just in case, unsure what needed referencing here
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");
});
}
不幸的是,当我运行此我得到如下:
'undefined' is not a constructor (evaluating 'new DMC.TreeBurst.Node({
id: 1,
parentId: null,
title: ""
})')
现在,我敢肯定这应该是一个构造函数,而是放肆和qUnit的组合似乎没有看到它在这样。
我花了一些时间寻找,但我发现的一切都表明,事情应该是'工作'。我在这里做了明显错误的事吗?
任何想法非常感谢。
编辑:在回应评论,这是类声明:
/// <reference path="references.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
}
}
你应该只能够做新的节点(....),因为你已经在TreeBurst命名空间。你还导出了你的节点类吗? –
@ N.TaylorMullen是的,我得到了相同的结果,不管它是否完全满足,我也导出了该类,将编辑问题以显示,以防我在那里做了错误的事情。 – dougajmcdonald