【问题标题】:Chutzpah doesn't detect jasmine tests in Typescript with AMD modulesChutzpah 没有在带有 AMD 模块的 Typescript 中检测到 jasmine 测试
【发布时间】:2020-01-19 11:23:59
【问题描述】:

我们正在尝试找出一种 UI 测试方法,并认为 chutzpah 将是一个不错的选择。 我使用 typescript 和 requirejs 编写了 jasmine 测试。 Chutzpah 能够检测不导入任何外部模块的示例测试。但是当我尝试导入要测试的外部模块时,chutzpah 似乎没有检测到测试资源管理器中的测试。 这是我的回购链接:https://github.com/NareshNow/UItesting.git

这是我的 chutzpah json 文件:

"Framework": "jasmine",
"TestHarnessReferenceMode": "AMD",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"AMDBaseUrl": "../Compiledmodules/Tests",
"AMDAppDirectory": "../Compiledmodules",
"TestFileTimeout": 600000,
"EnableCodeCoverage": false,
"References": [

{
  "Path": "../Scripts/require.js",
  "IsTestFrameworkFile": true
},
{
  "Path": "../Scripts/AMDconfig.js",
  "IsTestFrameworkFile": true
}
],
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ],
"SourceDirectory": "../Typescripts",
"OutDirectory": "../Compiledmodules"
},
"Tests": [
{
"Path": "../Typescripts",
"Includes": [ ".ts" ]
},
{
"Path": "../Compiledmodules",
"Includes": [".js"]
}
]
}

在过去的 5 天里,我尝试了很多关于类似问题的早期问题的建议,但似乎没有任何效果。对我来说,感觉就像缺少了一些简单的东西。 您可以在 repo 的 TypescripKit 文件夹中找到测试 chutzpah.json。 任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: typescript jasmine requirejs amd chutzpah


    【解决方案1】:

    我终于让它工作了。没时间在这里发帖。这就是问题所在。 我在 tsconfig.json 中针对 ES2015。 ES2015 不会将 typescript 类转换为函数,而是使用 class 关键字本身。 所以,我在我的 jasmine 测试中访问它的方式适用于 ES5,而且我在我的 jasmine 测试中的 describe 块开始之前声明了变量。这使得厚颜无耻不承认它们是测试。 因此,一旦我将目标更改为 ES5 并在 describe 中声明变量,chutzpah 就能够检测到测试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-22
      • 2016-08-05
      • 2017-01-17
      • 2016-05-28
      • 2015-09-13
      • 1970-01-01
      • 2017-05-14
      • 1970-01-01
      相关资源
      最近更新 更多