Question

I managed to set up JScover 0.2.0 on my Windows 7 to the point where I get to page on http://localhost:8080/jscoverage.html, and I can see test coverage for example working.

Jasmine test that I am attempting to run with JSCover for staters is 'jasmine-ObjectTreeStructure-Tests.js' file that is in /OnTheMoveWebFiles/js folder of my project. Jasmine other libraries and test files all reside in this same folder.
I normally run jasmine tests by running project in debug mode, then navigating to http://localhost:57263/FeatureDev/JavaScriptTestsWithDependencies.aspx.
This page contains jasmine, jquery, ... other dependencies and many jasmine test .js files that need to be tested.
How do I go around integrating JSCover into my JavaScriptTestsWithDependencies.aspx file so that it would check code coverage. JavaScriptTestsWithDependencies.aspx is very basic.

<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>

I have tried running JSCover in inverted mode window.open('path/to/jscoverage.html'); by adding

        window.open('http://localhost:8080/jscoverage.html');
        function execJasmine() {
            jasmineEnv.execute();
        }

just before execJasmine method, but that only opened jscoverage.html in popup with blank url.

Question: where and how do I plug in JSCover into this, and if it's not possible what are my options?

Was it helpful?

Solution

I managed to set up JScover 0.2.0

Firstly, why not grab the latest version from https://sourceforge.net/projects/jscover/files/?

I normally run jasmine tests by running project in debug mode, then navigating to http://localhost:57263/FeatureDev/JavaScriptTestsWithDependencies.aspx

OK, in that case you can't use JSCover in server mode. To get the JavaScript instrumented, so that it will work, you either have to run JSCover in proxy mode, or instrument the JavaScript manually using the file-system mode before going to http://localhost:57263/FeatureDev/JavaScriptTestsWithDependencies.aspx. There are examples for both approaches here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top