【问题标题】:Why Chutzpah does not recognize all TypeScript tests?为什么 Chutzpah 不能识别所有的 TypeScript 测试?
【发布时间】:2016-08-05 19:24:46
【问题描述】:

我有一个带有以下 chutzpah.json 的项目:

{
  "Framework": "jasmine",
  "TestHarnessReferenceMode": "AMD",
  "TestHarnessLocationMode": "SettingsFileAdjacent",
  "EnableTestFileBatching": true,

  "References": [
    { "Path": "node_modules/es6-shim/es6-shim.min.js" },
    { "Path": "node_modules/zone.js/dist/zone.min.js" },
    { "Path": "node_modules/reflect-metadata/Reflect.js" },
    { "Path": "node_modules/systemjs/dist/system.js" },
    { "Path": "system-config.js" }
  ],
  "CodeCoverageExcludes": ["node_modules/*"],
  "Tests": [
    { "Path": "app", "Includes": [ "*.spec.ts" ] }
  ]
}

以及以下测试文件

测试资源管理器只显示存储在第一个文件中的测试

如果我尝试运行 VSTest 的命令,我会得到相同的结果:

如果我调用设置文件名的命令(例如 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" app\InspectionDataView.spec.ts /UseVsixExtensions:true ),文件中的测试就会运行。

加分:

我尝试直接用 Chutzpah.console.exe 运行测试,这是我得到的:

我在这里错过了什么?

注意:使用 VS 2015 更新 3

【问题讨论】:

    标签: unit-testing typescript jasmine chutzpah


    【解决方案1】:

    Chutzpah 不运行 TypeScript。它“支持”它,但您必须在 chutzpah.json 中添加此支持。

    为什么第一个测试套件成功了?也许它是用纯 ES5 编写的(没有 ES6/TS 类、接口等)。

    我确实从这个 repo https://github.com/mmanela/chutzpah/tree/master/Samples/Compilation/TypeScript 设置了对打字稿的 chutzpah 支持

    基本上,简而言之:

    1. 创建一个将 TS 转换为 ES5 的 compile.bat。通常 - 带或不带 tsconfig.json 的 tsc.exe
    2. 添加“编译”部分,如 https://github.com/mmanela/chutzpah/blob/master/Samples/Compilation/TypeScript/chutzpah.json 所示

    每次运行 chutzpah.console.exe 时都会将 TS 转换为 ES5

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      • 2016-11-23
      相关资源
      最近更新 更多