Unit testing 在Webstorm中运行Typescript单元测试时出现问题
我正在尝试使用tsUnit为Typescript运行单元测试。我已经包括了tsUnit路径。我导入的方式似乎有问题Unit testing 在Webstorm中运行Typescript单元测试时出现问题,unit-testing,typescript,Unit Testing,Typescript,我正在尝试使用tsUnit为Typescript运行单元测试。我已经包括了tsUnit路径。我导入的方式似乎有问题 ///<reference path="tsUnit.ts" /> import testClass = tsUnit; class IDTest extends tsUnit.TestClass { selectIDTest() { ... this.areIdentical("#" + id, idSelector);
///<reference path="tsUnit.ts" />
import testClass = tsUnit;
class IDTest extends tsUnit.TestClass {
selectIDTest() {
...
this.areIdentical("#" + id, idSelector);
}
setAsRootTest() {
...
this.areIdentical("root", target.setAsRoot());
}
}
var test = new tsUnit.Test();
test.addTestClass(new IDTest());
test.showResults(document.getElementById('results'), test.run());
行
import testClass=tsUnit
不过是一个名称别名,即var testClass=tsUnit代码>不执行任何导入操作
假设您使用的是手动引用//
使用--out
标志编译并使用reference.ts对文件进行排序:难道--out标志不会将所有文件编译成单个文件吗?我不想通过将代码编译成单独的.js文件(每个.ts测试文件一个)来维护模块化。我对客户端JS文件使用RequireJS(根据您在上一个问题中提出的建议),而不是--out标志,因此如果我更改测试文件的设置,所有文件的设置都会更改,不是吗?您能建议一个命令行指令,只将tsUnit文件的内容包含到每个tsUnit测试文件中吗?
Uncaught ReferenceError: tsUnit is not defined IDTest.ts:8:21
(anonymous function) IDTest.ts:8:21
Uncaught SyntaxError: Unexpected token : chrome-extension://mgjjeipcdnnjhgodgjpfkffcejoljijf/shortcut_manager.js
(anonymous function) chrome-extension://mgjjeipcdnnjhgodgjpfkffcejoljijf/shortcut_manager.js
(anonymous function) extensions::messaging
target.(anonymous function) extensions::SafeBuiltins
Event.dispatchToListener extensions::event_bindings
Event.dispatch_ extensions::event_bindings
Event.dispatch extensions::event_bindings
dispatchOnMessage extensions::messaging