Question

How can I get essentially 0% coverage reported for files that are not loaded during tests. This feature could help me in identifying files I forget to write tests for

Était-ce utile?

La solution

As of Intern 1.6, there is no way to do this out-of-the-box, but you could write a custom reporter that extends one of the coverage reporters, and at the conclusion of the testing (in the stop method of the reporter), loads a list of all other files from the directory you are concerned about and adds empty coverage objects for them to the collector. Something like this:

define([
  'intern/lib/reporters/lcovhtml',
  'intern/dojo/topic'
], function (lcovhtml, topic) {
  var reporter = Object.create(lcovhtml);

  reporter.stop = function () {
    var files = getFiles();
    for (var i = 0, file; (file = files[i]); ++i) {
      topic.publish('/coverage', createCoverageForFile(file));
    }

    lcovhtml.stop();
  };
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top