Constellation / ibrik

CoffeeScript meets Istanbul - code coverage tool for CoffeeScript
BSD 2-Clause "Simplified" License
79 stars 32 forks source link

Possible bug fix for reporting coverage with grunt-karma, karma-jasmine and karma-coverage #28

Closed mattxo closed 8 years ago

mattxo commented 9 years ago

Hi,

I've found that in ibrik/instrumenter.js, the code that is passed into Istanbul is compiled without the bare : true option.

 Instrumenter.prototype.instrumentSync = function(code, filename) {
      var e, program;
      filename = filename || ("" + (Date.now()) + ".js");
      if (typeof code !== 'string') {
        throw new Error('Code must be string');
      }
      try {
        code = coffee.compile(code, {
            sourceMap: true,
            *** bare : true ***
        });
        program = esprima.parse(code.js, {
          loc: true
        });
        this.fixupLoc(program, code.sourceMap);
        return this.instrumentASTSync(program, filename, code);
      } catch (_error) {
        e = _error;
        e.message = "Error compiling " + filename + ": " + e.message;
        throw e;
      }
    };

Karma kept reporting that my classes in CoffeeScript were undefined until I added that compiler flag in the ibrik source!

ardelio commented 9 years ago

The exact same problem, and this also fixed it for me.