我想让Chutzpah和Jasmine在visual studio中一起工作,我的最终目标是让TeamCity集成运行单元测试。
在保存时,所有打字稿代码都会生成一个.js
文件。这也导致Chutzpah运行我的测试,到目前为止一切顺利。
我的问题是Chutzpah报告0传递,0失败和0错误。生成的Jasmine html文件正确列出了我的所有测试,但Chutzpa似乎没有从Jasmine收到任何信息。
跟踪日志的重点:
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
(我检查了站点范围的文件,我的测试被附加到它上面)。
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
{
"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
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没有报告。
答案 0 :(得分:1)
也许迟到了...... 但是chutzpah.json中的这样的东西会有所帮助。
{
"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”