我将 TypeScript 1.0 与 Visual Studio 2012、Chutzpah 3.2.1.1 和 Jasmine 2 一起使用。
我有一个非常基本的测试,可以很好地编译,但使用 Visual Studio Chutzpah 测试适配器或命令行没有通过。
我收到以下错误
ReferenceError:找不到变量:MyProject in....
我的项目结构如下:
**solution**
TypeScriptProject
X.ts
TestProject
chutzpah.json
compile.bat
Scripts\(contains typings)
Spec
TestX.ts
TypeScriptProject\X.ts
module MyProject {
export class X {
getValue(): number {
return 5;
}
}
}
测试项目\chutzpah.json
{
"Framework": "jasmine",
"Compile": {
"Extensions": [".ts"],
"ExtensionsWithNoOutput": [".d.ts"],
"Executable": "compile.bat"
},
"References": [
{ "Path": "../TypeScriptProject/X.ts"}
],
"Tests": [
{ "Path": "Spec"}
]
}
TestProject\compile.bat
@echo off
tsc Spec/TestX.ts ../TypeScriptProject/X.ts --sourcemap
TestProject\Spec\TestX.ts
/// <reference path="../Scripts/typings/jasmine/jasmine.d.ts"/>
/// <reference path="../../TypeScriptProject/X.ts"/>
describe("test x value", function(){
it("should", function(){
var x = new MyProject.X();
expect(x.getValue()).toEqual(5);
});
});
由于它编译得很好,TestX.ts 中的引用应该是正确的。
我的问题似乎与在 TFS 2012 中运行 Jasmine 的 Chutzpah 不同,因为我在 Visual Studio 测试运行程序中遇到错误并且似乎在谈论使用 Team Build,所以找不到被测试的引用文件。