Sha256: 06093f3a04e4ea399670b261691bb224f740c00757c0859416a529e229b5ac0b

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

(function (){
  window.CUCUMBER_BLANKET = {
    files: {},
    sources: {},
    done: false,
    is_setup: false
  };
  /* ADAPTER
   *
   * This blanket.js adapter is designed to autostart coverage
   * immediately. The other side of this is handled from Cucumber
   *
   * Required blanket commands:
   * blanket.setupCoverage(); // Do it ASAP
   * blanket.onTestStart(); // Do it ASAP
   * blanket.onTestDone(); // After Scenario Hook (Not necessary)
   * blanket.onTestsDone(); // After Scenario Hook
   */

  blanket.beforeStartTestRunner({
    callback: function() {
      blanket.setupCoverage();
      blanket.onTestStart();
      window.CUCUMBER_BLANKET.is_setup = true;
    }
  });


  /* REPORTER
   *
   * Blanket.js docs speak of blanket.customReporter but
   * that doesn't actually work so we'll override defaultReporter
   */
  blanket.defaultReporter = function(coverage_results){
    window.CUCUMBER_BLANKET.files = coverage_results.files;
    // Strangely enough it looks like we need to iterate in order to grab the `source`
    // data which is necessary to know which lines of code are being reported on.
    var files = Object.keys(coverage_results.files);
    for (var i = 0, l = files.length; i < l; i ++) {
      var file = files[i];
      window.CUCUMBER_BLANKET.sources[file] = window.CUCUMBER_BLANKET.files[file].source;
    }
    window.CUCUMBER_BLANKET.done = true;
    // Now we can grab all this on the selenium side through window.CUCUMBER_BLANKET
  };
})();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-blanket-0.3.0 javascript/cucumber-blanket.js