我在Visual 2012、chutzpah3.2.1.1和Jasmin-2中使用TypeScript 1.0。
我有一个非常基本的测试,它编译得很好,但没有使用或命令行1通过。
我得到以下错误
ReferenceError:找不到变量: MyProject在.
我的项目结构如下:
**solution**
TypeScriptProject
X.ts
TestProject
chutzpah.json
compile.bat
Scripts\(contains typings)
Spec
TestX.tsTypeScriptProject\X.ts
module MyProject {
export class X {
getValue(): number {
return 5;
}
}
}TestProject\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中的引用应该是正确的。
我的问题似乎与Chutzpah running Jasmine in TFS 2012 can't find referenced file under test不同,因为我在Visual测试运行程序中得到了错误,并且似乎在谈论使用团队构建。
发布于 2014-05-19 14:33:23
默认情况下,Chutzpah假定要编译的源和输出目录是chutzpah.json文件的位置。但是,在您的例子中,这些目录应该更高一点,因为您正在编译的.ts文件并不在chutzpah.json文件的位置或下面。
因此,通过将sourcedirectory和outdirectory添加到编译设置中,它将工作得很好:
{
"Framework": "jasmine",
"Compile": {
"Extensions": [".ts"],
"ExtensionsWithNoOutput": [".d.ts"],
"Executable": "compile.bat",
"SourceDirectory": "../",
"OutDirectory": "../",
},
"References": [
{ "Path": "../TypeScriptProject/X.ts"}
],
"Tests": [
{ "Path": "Spec"}
]
}https://stackoverflow.com/questions/23734687
复制相似问题