首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Chutzpah和Jasmine类型单位测试

Chutzpah和Jasmine类型单位测试
EN

Stack Overflow用户
提问于 2018-03-27 23:56:25
回答 1查看 789关注 0票数 4

我试图让Chutzpah和Jasmine一起在visual中工作,我的最终目标是让单元测试与TeamCity集成一起运行。

在保存时,所有类型记录代码都生成一个.js文件。这也会导致Chutzpah运行我的测试,到目前为止还不错。

我的问题是Chutzpah报告0通过,0失败和0错误。生成的Jasmine文件正确地列出了我的所有测试,但是Chutzpa似乎没有收到任何来自Jasmine的信息。

跟踪日志的突出显示:

代码语言:javascript
复制
Trying to build test context for c:\.....\test.ts
Building test context for c:\.....\test.ts
...framework dependencies / other ok looking things... (~15 lines)
Finished building test context for c:\.....\test.ts
Warning: 0 : Message:Chutzpah determined generated .js files are missing but the compile 
mode is External so Chutzpah can't compile them. Test results may be wrong.

然后启动Phantom js并记录加载/接收资源。我的test.ts文件不是列出的资源之一,但是站点范围的.js是(我检查了站点范围的文件,我的测试被附加到它)。

代码语言:javascript
复制
Finished test run for c:\......\test.ts in Discovery mode
Cleaning up test context for c:\......\test.ts
Chutzpah run finished with 0 passed, 0 failed and 0 errors
Chutzpah.json file cache cleared
End Test Adapter Discover Tests

chutzpah.json

代码语言:javascript
复制
{
  "Framework": "jasmine",  
  "EnableTestFileBatching": true,
  "Compile": {
    "Mode": "External",
    "Extensions": [ ".ts" ],
    "ExtensionsWithNoOutput": [ ".d.ts" ],
    "Paths": [
      {
        "OutputPath": "../SiteWide.js",
        "SourcePath": "Views"
      }
    ]
  },
  "References": [
    {
      "Path": "../knockout-3.4.2.js",
      "IsTestFrameworkFile": true
    }
  ],
  "Tests": [
    {
      "Includes": [ "*.ts" ],
      "Path": "../Tests/Views"
    }
  ],
  "EnableTracing": true,
  "TraceFilePath": "./trace.log"
}

tests.ts

代码语言:javascript
复制
describe('configuring unit tests for typescript!', () => {
    it('this should pass', () => {
        expect(1).toBe(1);
    });

    it('this should fail', () => {
        expect(1).toBe(0);
    });
});

有几件事我很怀疑(跟踪中缺少的.js文件行--但这可能只是由我的单个js文件编译步骤引起的?)

也许我在chutzpah.json里漏掉了茉莉花的参考资料?

我不明白为什么茉莉花测试有效,但Chutzpah不报告。

EN

回答 1

Stack Overflow用户

发布于 2018-05-07 16:08:42

也许晚了..。但是在chutzpah.json中这样的东西会有帮助。

代码语言:javascript
复制
{
"Framework": "jasmine",
"Compile": {
    "Mode": "External",
    "Extensions": [ "*.ts" ],
    "ExtensionsWithNoOutput": [ "*.d.ts" ]
},
"References": [
    { "Path": "node_modules/promise-polyfill/dist", "Include": "*.js", "Exclude": "*.d.ts" },
    { "Path": "node_modules/systemjs/dist", "Include": "*.js", "Exclude": "*.d.ts" }
],
"Tests": [
    { "Path": "unittests", "Includes": [ "*.spec.ts" ], "Excludes": [ "*.d.ts" ], "ExpandReferenceComments": "true" }
]

}

在引用中,拥有与系统相关的文件非常重要。您也可以在测试部分中尝试"*.spec.js“。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49524099

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档