gpt4 book ai didi

typescript - 当我使用 Chutzpah.json 文件时使用 Chutzpah 运行测试时出现问题

转载 作者:搜寻专家 更新时间:2023-10-30 22:07:06 24 4
gpt4 key购买 nike

当我提供 Chutzpah.json 文件时,我无法让 Chutzpah 运行我的 typescript 测试。

我的项目是这样的:

enter image description here

我的 Chutzpah.json 文件如下所示:

{
"Compile": {
"Mode": "External",
"ExtensionsWithNoOutput": [ ".d.ts" ]
},
"Tests": [
{ "Include": "**/**.ts","Exclude": "**/**.d.ts" }
],
"References": [
{"Include": "../../hacapp.web/**/*.ts", "Exclude": "../../hacapp.web/**/**.d.ts" }
]
}

当我使用这个 Chutzpah.json 文件运行时,会执行 0 个测试。使用这些参数运行命令行运行程序的输出:

chutzpah.consle.exe /path \hacapp.web\hacapp.web.Tests\Scrpts\TypescriptTests.ts /trace /debug

is here

生成的 html 文件的内容似乎不包含对 TypescriptTests.js 文件的任何引用:

<head>
<meta charset="utf-8" />
<title>QUnit Tests</title>
<link rel="stylesheet" type="text/css" href="file:///C:/Users/sam/Source/Repos/chutzpah-master/ConsoleRunner/bin/Debug/TestFiles/QUnit/qunit.css"/>
<script type="text/javascript" src="file:///C:/Users/sam/Source/Repos/chutzpah-master/ConsoleRunner/bin/Debug/TestFiles/QUnit/qunit.js"></script>
<script type="text/javascript" src="file:///C:/Users/sam/Source/Repos/haccpapp/hacapp.web/hacapp.web/scripts/jquery-1.10.2.js"></script>
<script type="text/javascript" src="file:///C:/Users/sam/Source/Repos/haccpapp/hacapp.web/hacapp.web/scripts/knockout-3.0.0.js"></script>
<script>
var amdTestPath = "";
if (window.require && typeof window.require === "function" && amdTestPath !== "") {
if (window.chutzpah) {
window.chutzpah.usingModuleLoader = true;
}

requirejs.config({
map: {
'*': {

}
}
});

window.QUnit.config.autostart = false;
window.require([amdTestPath], function () {
console.log("!!_!! Starting QUnit from inline AMD call...");
if (!window._Chutzpah_covobj_name) {
window.QUnit.start();
}
});
}
</script>
</head>

如果我随后重命名 Chutzpah.json 文件,使其不再被使用,然后再次运行命令行工具,那么这次它会运行测试和 this is in the log file ,这就是 html 的样子:

<head>
<meta charset="utf-8" />
<title>QUnit Tests</title>
<link rel="stylesheet" type="text/css" href="file:///C:/Users/sam/Source/Repos/chutzpah-master/ConsoleRunner/bin/Debug/TestFiles/QUnit/qunit.css"/>
<script type="text/javascript" src="file:///C:/Users/sam/Source/Repos/chutzpah-master/ConsoleRunner/bin/Debug/TestFiles/QUnit/qunit.js"></script>
<script type="text/javascript" src="file:///C:/Users/sam/Source/Repos/haccpapp/hacapp.web/hacapp.web/scripts/Workflow/_Chutzpah.1.WFDefinition.js"></script>
<script type="text/javascript" src="file:///C:/Users/sam/Source/Repos/haccpapp/hacapp.web/hacapp.web/scripts/jquery-1.10.2.js"></script>
<script type="text/javascript" src="file:///C:/Users/sam/Source/Repos/haccpapp/hacapp.web/hacapp.web/scripts/knockout-3.0.0.js"></script>
<script type="text/javascript" src="file:///C:/Users/sam/Source/Repos/haccpapp/hacapp.web/hacapp.web.Tests/Scripts/_Chutzpah.1.TypescriptTests.js"></script>
<script>
var amdTestPath = "";
if (window.require && typeof window.require === "function" && amdTestPath !== "") {
if (window.chutzpah) {
window.chutzpah.usingModuleLoader = true;
}

requirejs.config({
map: {
'*': {

}
}
});

window.QUnit.config.autostart = false;
window.require([amdTestPath], function () {
console.log("!!_!! Starting QUnit from inline AMD call...");
if (!window._Chutzpah_covobj_name) {
window.QUnit.start();
}
});
}
</script>
</head>

<body>
<h1 id="qunit-header">Unit Tests</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"></div>
</body>
</html>

我在配置上做错了什么?

最佳答案

更新的答案

我根据给出的完整重现更新答案。原答案保留在下方。

问题是,默认情况下,chutzpah 会将源目录设置为在 chutzpah.json 文件的位置查找生成的脚本。将其设置为源文件夹和测试文件夹的父文件夹可解决此问题

{
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ],
"SourceDirectory": "../../",
"OutDirectory": "../../"
},
"Tests": [
{ "Include": "*/*.ts","Exclude": "*/*.d.ts" }
],
"References": [
{"Include": "../../ChutzpaWeb/*/*.ts", "Exclude": "../../ChutzpaWeb/*/*.d.ts" }
]
}

原始答案

在没有完整重现的情况下,我无法确认这是否能解决您的问题,但我确实解决了几个问题。

{
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ]
},
"Tests": [
{ "Include": "*/*.ts","Exclude": "*/*.d.ts" }
],
"References": [
{"Include": "../../hacapp.web/*/*.ts", "Exclude": "../../hacapp.web/*/*.d.ts" }
]
}
  1. 我将 Extensions 元素添加到您的编译节点,以便 Chutzpah 知道要考虑输入 .ts 文件
  2. 我将 ** 更改为 *。这不会导致您的问题,但不需要 **,因为 * 匹配 1 个或多个字符包括斜杠。

如果有帮助,请告诉我。

关于typescript - 当我使用 Chutzpah.json 文件时使用 Chutzpah 运行测试时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26724360/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com