我正在使用chutzpah将我的javascript单元测试与TFS 2015集成,并且完美地完成了。
但是在启用代码覆盖时,我会收到与文件路径相关的错误
e.g。
错误:Blanket.js在遇到交叉原始请求时出错 检测源文件。这很可能是由来源引起的 本地引用的文件(使用file://协议)。
因为当chutzpah为每个测试文件生成html文件时,引用路径不是相对的:
<script type="text/javascript" src="file:///C:/_work/7b9b5f73/MyProject/packages/Chutzpah.4.2.3/tools/TestFiles/chutzpah_boot.js"></script>
我研究了如何配置chutzpah设置以使路径相对,最匹配的答案是Customizable HTML harness generation,其中说明了如何覆盖整个模板而不是覆盖默认模板中的占位符。
那么有没有办法配置chutzpah来建立引用路径相对于能够将客户端代码覆盖率结果与tfs链接。
我的chutzpah.json文件如下所示:
{
"Framework": "mocha",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"RootReferencePathMode": "SettingsFileDirectory",
"EnableCodeCoverage": "true",
"CodeCoverageExcludes": [
"bower_components\\*",
"node_modules\\*"
],
"References": [
{
"Path": "node_modules/mocha/mocha.js"
},
{
"Path": "node_modules/chai/chai.js"
},
{
"Path": "node_modules/sinon-chai/lib/sinon-chai.js"
},
{
"Path": "src/client/app/mochaConstrutor.js"
},
{
"Path": "bower_components/jquery/dist/jquery.js"
},
{
"Path": "bower_components/angular/angular.js"
},
{
"Path": "bower_components/angular-sanitize/angular-sanitize.js"
},
{
"Path": "bower_components/bootstrap/dist/js/bootstrap.js"
},
{
"Path": "bower_components/extras.angular.plus/ngplus-overlay.js"
},
{
"Path": "bower_components/moment/moment.js"
},
{
"Path": "bower_components/angular-ui-router/release/angular-ui-router.js"
},
{
"Path": "bower_components/toastr/toastr.js"
},
{
"Path": "bower_components/angular-animate/angular-animate.js"
},
{
"Path": "bower_components/angular-bootstrap/ui-bootstrap-tpls.js"
},
{
"Path": "bower_components/angular-mocks/angular-mocks.js"
},
{
"Path": "bower_components/sinon/index.js"
},
{
"Path": "bower_components/bardjs/dist/bard.js"
},
{
"Path": "bower_components/bardjs/dist/bard-ngRouteTester.js"
},
...
],
"Tests": [
{
"Path": "src/client/app/admin/admin.controller.spec.js"
},
{
"Path": "src/client/app/admin/admin.route.spec.js"
},
...
]
}
答案 0 :(得分:1)
目前,Chutzpah没有办法制作相对路径。但是,我目前正在进行一项更改,它将使其与嵌入式Web服务器一起运行,这将使像Blanket这样的工具更加顺畅。