Chutzpah找不到变量

第1行

我将TypeScript 1.0与Visual Studio 2012,Chutzpah 3.2.1.1和Jasmine 2一起使用。

我有一个非常基本的测试,可以正常编译,但是使用Visual Studio Chutzpah测试适配器或命令行无法通过。

我收到以下错误

ReferenceError:找不到变量:MyProject在...。

我的项目的结构如下:

**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;
        }
    }
}

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 \规范\ 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,因此无法找到被测试的引用文件

马修·曼妮拉(Matthew Manela)

默认情况下,Chutzpah假定chutzpah.json文件的位置为编译的源和出目录。但是,在这种情况下,由于您正在编译不在chutzpah.json文件位置以下的.ts文件,因此这些目录应该高一。

因此,通过将sourcedirectory和outdirectory添加到编译设置中,将可以正常工作:

{
 "Framework": "jasmine",
 "Compile": {
   "Extensions": [".ts"],
   "ExtensionsWithNoOutput": [".d.ts"],
   "Executable": "compile.bat",
   "SourceDirectory": "../",
   "OutDirectory": "../",
  },
"References": [
    { "Path": "../TypeScriptProject/X.ts"}
],
 "Tests": [
   { "Path": "Spec"}
 ]
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章