我设法在我的 Windows 7 上设置了 JScover 0.2.0 到可以打开页面的位置http://localhost:8080/jscoverage.html
,并且我可以看到测试覆盖率,例如工作。
我尝试使用 JSCover 为 staters 运行的 Jasmine 测试是我项目文件夹'jasmine-ObjectTreeStructure-Tests.js'
中/OnTheMoveWebFiles/js
的文件。Jasmine 的其他库和测试文件都位于同一个文件夹中。
我通常通过在调试模式下运行项目来运行 jasmine 测试,然后导航到http://localhost:57263/FeatureDev/JavaScriptTestsWithDependencies.aspx
.
此页面包含 jasmine、jquery、... 其他依赖项以及许多需要测试的 jasmine 测试 .js 文件。
如何将 JSCover 集成到我的JavaScriptTestsWithDependencies.aspx
文件中,以便检查代码覆盖率。
JavaScriptTestsWithDependencies.aspx
非常基础。
<script type="text/javascript">
(function () {
"use strict";
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 250;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function (spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function () {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
我尝试
通过添加以倒置模式运行 JSCover window.open('path/to/jscoverage.html');
window.open('http://localhost:8080/jscoverage.html');
function execJasmine() {
jasmineEnv.execute();
}
就在 execJasmine 方法之前,但这只在弹出窗口中打开了 jscoverage.html 并带有空白 url。
问题:我在哪里以及如何将 JSCover 插入其中,如果不可能,我的选择是什么?