0

我设法在我的 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 插入其中,如果不可能,我的选择是什么?

4

1 回答 1

1

我设法设置了 JScover 0.2.0

首先,为什么不从https://sourceforge.net/projects/jscover/files/获取最新版本?

我通常通过在调试模式下运行项目来运行 jasmine 测试,然后导航到http://localhost:57263/FeatureDev/JavaScriptTestsWithDependencies.aspx

好的,在这种情况下,您不能在服务器模式下使用 JSCover。要检测 JavaScript 以使其正常工作,您必须在代理模式下运行 JSCover ,或者在转到 之前使用文件系统模式手动检测 JavaScript http://localhost:57263/FeatureDev/JavaScriptTestsWithDependencies.aspx这里有两种方法的示例。

于 2014-04-29T10:25:36.527 回答