jscover icon indicating copy to clipboard operation
jscover copied to clipboard

jsCoverage not working with Squire.js dependency injection

Open d215steinberg opened this issue 11 years ago • 0 comments

We are injecting mocks into our code using squire.js. Code covered by such tests is not being reported as covered.

EXAMPLE:

require(['Foo'], function(foo)  {
      describe('Foo', function() {
         it('should do bar', function() {
             foo.bar();
             foo.should...
        });
    });
});

Coverage is reported for Foo.js.

BUT:

describe('Foo', function() {
   it('should do bar', function() {
      var Squire = require('squirejs');
      var sinon = require('sinon');
      var injector = new Squire();
      var bamSpy = sinon.spy();
      var mockBaz = {
            bam: bamSpy
     }
      injector.mock('baz', mockBaz)
           .require(['Foo'], function(foo) {
                foo.bar();
                sinon.assert.called(bamSpy);
      });
   });
});

No coverage is reported for Foo.js.

We are using up-front instrumentation. We are using a fork of jscoverage 0.3.7.

d215steinberg avatar Mar 21 '14 17:03 d215steinberg