无法使用TypeScript引用与Chutzpah一起使用

时间:2015-12-14 15:03:18

标签: typescript chutzpah

我的项目文件夹中有以下文件:

  • chai.d.ts
  • chai.js
  • mocha.d.ts
  • mocha.js
  • appTest.ts
  • appTest.js
  • chutzpah.json

使用bower和tsd

下载了chai和mocha文件

以下是其他文件中的内容:

appTest.ts:

/// <chutzpah_reference path="mocha.js" />
/// <chutzpah_reference path="chai.js" />
/// <reference path="mocha.d.ts" />
/// <reference path="chai.d.ts" />
var assert = chai.assert;

test("test test", function () {
    assert.equal(1, 3, "One equals three");
});

appTest.js:(由外部流程编译)

var assert = chai.assert;
test("test test", function () {
    assert.equal(1, 3, "One equals three");
});

chutzpah.json:

{
  "Compile": {
    "Mode": "External",
    "Extensions": [ ".ts" ],
    "ExtensionsWithNoOutput": [ ".d.ts" ]
  },
  "Tests": [
    {
      "Includes": [ "*Test.ts" ]
    }
  ]
}

我在文件夹中运行此命令:

chutzpah.console appTest.ts

我收到以下错误:

Chutzpah console test runner  (64-bit .NET 4.0.30319.42000)
Version 4.1.0.0
Copyright (C) 2015 Matthew Manela (http://matthewmanela.com).


Error: ReferenceError: Can't find variable: chai
at global code in file:///C:/***/appTest.js (line 1)

While Running:C:\***\appTest.ts

File: C:\***\appTest.ts
     0 total, 0 failed, took 0.00 seconds

Tests complete: 0
=== 0 total, 0 failed, took 1.65 seconds ===

我错过了什么?

1 个答案:

答案 0 :(得分:2)

我认为你正在进行4.1版本中引入的重大变化,关于Chutzpah在使用Cutzpah.json文件时如何解析文件引用。作为一个性能变化,Chutzpah使测试文件中的扫描引用成为一个可选功能,并且更喜欢在Chutzpah.json文件中明确列出它们。

有关详细信息,请参阅this page

但基本上,你需要在chutzpah.json文件中引用你需要的文件:

 "References": [
    {
      "Path": "chai.js"
    }
  ]

或标记您的测试文件以允许扫描参考:

  "Tests": [
        { "Includes": [ "*Test.ts" ], "ExpandReferenceComments":  "true" }
    ]