无法获得与 Chutzpah 一起使用的 TypeScript 参考
Can't get TypeScript reference to work with 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 ===
我错过了什么?
我认为您遇到了 4.1 版中引入的重大更改,即 Chutzpah 在使用 Cutzpah.json 文件时如何解析文件引用。作为性能改进,Chutzpah 使扫描测试文件中的引用成为一项可选功能,并且更喜欢您在 Chutzpah.json 文件中明确列出它们。
有关详细信息,请参阅 this page。
但基本上,要么你需要在chutzpah.json文件中引用你需要的文件:
"References": [
{
"Path": "chai.js"
}
]
或标记您的测试文件以允许扫描引用:
"Tests": [
{ "Includes": [ "*Test.ts" ], "ExpandReferenceComments": "true" }
]
我的项目文件夹中有以下文件:
- 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 ===
我错过了什么?
我认为您遇到了 4.1 版中引入的重大更改,即 Chutzpah 在使用 Cutzpah.json 文件时如何解析文件引用。作为性能改进,Chutzpah 使扫描测试文件中的引用成为一项可选功能,并且更喜欢您在 Chutzpah.json 文件中明确列出它们。
有关详细信息,请参阅 this page。
但基本上,要么你需要在chutzpah.json文件中引用你需要的文件:
"References": [
{
"Path": "chai.js"
}
]
或标记您的测试文件以允许扫描引用:
"Tests": [
{ "Includes": [ "*Test.ts" ], "ExpandReferenceComments": "true" }
]