[英]Trouble running Typescript Unit Tests in Webstorm
I am trying to run Unit Tests for Typescript using tsUnit. 我正在尝试使用tsUnit运行Typescript的单元测试。 I have included the tsUnit path.
我已经包含了tsUnit路径。 There seems to be something wrong with the way I've imported it.
我导入它的方式似乎有问题。
///<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());
Here's the error: 这是错误:
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
The line import testClass = tsUnit;
该行
import testClass = tsUnit;
is nothing more than a name alias ie var testClass = tsUnit;
只不过是一个名字别名,即
var testClass = tsUnit;
Does not do any importing whatsoever. 不执行任何导入。
Given that you are using a manual reference ///<reference path="tsUnit.ts" />
compile using the --out
flag and use a reference.ts to order your files : https://github.com/basarat/grunt-ts#javascript-generation-and-ordering 假设您使用的是手动参考
///<reference path="tsUnit.ts" />
使用--out
标志进行编译,并使用reference.ts对文件进行排序: https : //github.com/basarat/ grunt-ts#javascript生成和排序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.