Before my question I'll give some context on the libraries I'm using

  1. Unit Test Framework : Jasmine 1.3.1
  2. AMD Loader : RequireJS
  3. Code Coverage Tool : Blanket

My unit tests are all setup. I've been trying to get some test coverage of a small module of my application. (As small as 1 src file and 1 unit test file). After a lot of Googling and stackoverflowing I got Blanket configured to work inside my main SpecRunner.js.

Here is my SpecRunner.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>Jasmine Spec Runner</title>
  <link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png">
  <link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
<script src="lib/blanket/blanket.min.js"></script>
  <script type="text/javascript" src="../../require-2.1.4.min.js" data-main="SpecRunner"></script>
  

  
</head>
<body>

</body>
</html>

Here is my SpecRunner.js

require.config({
    urlArgs: 'cb=' + Math.random(),
    paths: {
        'jquery': '../../../libs/jquery',
        'jquery-ui': '../../../libs/jquery-ui',
        'bootstrap': '../../../libs/bootstrap-2.3.1.min',
        'jasmine': 'lib/jasmine-1.3.1/jasmine',
        'jasmine-html': 'lib/jasmine-1.3.1/jasmine-html',
        'blanket-jasmine': 'lib/blanket/jasmine-blanket',
        'js': '../../'
    },
    shim: {
        'jquery-ui': {
            deps: ['jquery']
        },
        'jasmine': {
            exports: 'jasmine'
        },
        'jasmine-html': {
            deps: ['jasmine'],
            exports: 'jasmine'
        },
        'blanket': {
            deps: ['jasmine']
        },
        'blanket-jasmine': {
            exports: 'blanket',
            deps: ['jasmine']
        }
    }
});

require(['jquery', 'jasmine-html', 'jquery-ui', 'bootstrap','blanket-jasmine'],
    function ($, jasmine, jquery_ui, bootstrap  , blanketjas  ) {
    'use strict';

    blanketjas.options('filter', "['../jquery.widget.richtext.js','test/spec/jquery.widget.richtext.spec.js']"); // data-cover-only
    blanketjas.options('branchTracking', true); // one of the data-cover-flags
    blanketjas.options('debug', true);

    var jasmineEnv = jasmine.getEnv();
    jasmineEnv.updateInterval = 1000;

    var htmlReporter = new jasmine.HtmlReporter();

    jasmineEnv.addReporter(htmlReporter);

    jasmineEnv.specFilter = function (spec) {
        return htmlReporter.specFilter(spec);
    };

    var specs = [];
    specs.push('spec/jquery.widget.richtext.spec');

    $(function () {
        require(specs, function () {
            jasmineEnv.addReporter(new jasmine.BlanketReporter());
            jasmineEnv.currentRunner().execute();
            // jasmineEnv.execute();
        });
    });

});

I got a lot of help configuring the SpecRunner.js from this post

Although there's a little change, for example I execute the runner when document has loaded.

I don't see any errors, but there is no coverage report too! I see all my tests passing! According to Blanket's GitHub page the coverage report should be right below my unit tests like in this example

Here is my console:

BLANKET-Test event started
BLANKET-Test event started
BLANKET-Test event started
BLANKET-Test event done
BLANKET-Reporting No files were instrumented

Why doesn't Blanket show any coverage report?

0

There are 0 best solutions below