Search code examples
javascriptunit-testingcommandjasminejscoverage

Jasmine JSCover no instrument does not work


I must be missing something here. I have Jasmine test and I am looking to check what coverage that test has on onTheMove-Tree.js file.
I am using default example server setup server runs on http://localhost:8080/jscoverage.html?/index.html.
I have modified index.html file to include dependencies (code at the bottom of post) that I have placed in \doc\example\dependencies in same folder is my Jasmine test file 'jasmine-OnTheMove-OnTheMove_ObjectTreeStructure-Tests.js'.
File that I intend to get test coverage for onTheMove-Tree.js is in doc\example directory in the same directory that index.html is. I am starting server with following command:

C:\Users\Administrator\Downloads\JSCover-0.2.0>java -jar target/dist/JSCover-all
.jar -ws --branch --document-root=doc/example --no-instrument=doc/example/depend
encies

However I can see files in dependencies folder being modified (check screenshot), this then results in all tests failing (same screenshot). Why is JSCover instrumenting files in \doc\example\dependencies? enter image description here

Index.html code:

<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>JavaScript Tests</title>

<script type="text/javascript">
    window.onTheMoveTest = {};
</script>

<script type="text/javascript" src="/dependencies/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/dependencies/ua-parser.min.js"></script>
<script type="text/javascript" src="/dependencies/knockout-3.0.0.custom.min.js">    </script>
<script type="text/javascript" src="/dependencies/knockout.validation.js"></script>
<script type="text/javascript" src="onTheMove-Tree.js"></script>
<script type="text/javascript" src="/dependencies/jasmine.js"></script>
<script type="text/javascript" src="/dependencies/jasmine-html.js"></script>
<script type="text/javascript" src="/dependencies/jasmine-jquery-1.7.0.js"></script>
<script type="text/javascript" src="/dependencies/jasmine-OnTheMove-OnTheMove_ObjectTreeStructure-Tests.js"></script>

<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>
</head>
<body></body></html>

Solution

  • The --no-instrument=URL is URL path based, not file-system based, so you need --no-instrument=/dependencies