使用Chutzpah.json文件时,使用Chutzpah运行测试的问题

Sam*_*der 1 qunit chutzpah typescript

当我提供Chutzpah.json文件时,我在让Chutzpah运行我的打字稿测试时遇到问题.

我的项目看起来像这样:

在此输入图像描述

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

{
    "Compile": {
        "Mode": "External",
        "ExtensionsWithNoOutput": [ ".d.ts" ]
    },
    "Tests": [
        { "Include": "**/**.ts","Exclude": "**/**.d.ts" }
    ],
    "References": [
        {"Include": "../../hacapp.web/**/*.ts", "Exclude": "../../hacapp.web/**/**.d.ts" }
    ]
}
Run Code Online (Sandbox Code Playgroud)

当我使用这个Chutzpah.json文件运行时,执行0测试.使用以下参数运行命令行运行器的输出:

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

在这儿

生成的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> 
Run Code Online (Sandbox Code Playgroud)

如果我然后重命名Chutzpah.json文件,使其不再使用,然后再次运行命令行工具,这次它运行测试,这是在日志文件中,这就是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>
Run Code Online (Sandbox Code Playgroud)

我配置错误了什么?

Mat*_*ela 6

更新的答案

我根据给出的完整repro更新答案.原始答案保留在下面.

问题是默认情况下chutzpah会将sourcedirectory设置为查找生成的脚本到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" }
    ]
}
Run Code Online (Sandbox Code Playgroud)

原始答案

没有完整的repro我无法确认这是否会解决您的问题,但我确实解决了几个问题.

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

如果有帮助,请告诉我.