Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support code-coverage instrumentation #52

Open
cstickel opened this issue Jan 22, 2018 · 2 comments
Open

Support code-coverage instrumentation #52

cstickel opened this issue Jan 22, 2018 · 2 comments

Comments

@cstickel
Copy link

I tried inject-loader with Typescript and Istanbul coverage.

For the code:

import getFoo from 'getFoo';

The inject-loader adds a logical or-expression. The result looks like:

var getFoo_1 = __getInjection("getFoo") || __webpack_require__(2);

If the depedency is mocked in all tests and the actual module is never used, the right side of the or-expression is never executed. This results in an uncovered branch in the coverage report.

@plasticine
Copy link
Owner

@mixer2 Hey there — yep, working around Istanbul (coverage in general) is pretty tricky. It’s something I’d love to support but have been unable to find the time to explore how (and if) it can be done. Sorry for the inconvenience.

@plasticine plasticine changed the title Wrong branch coverage Support code-coverage instrumentation Apr 7, 2018
@eugeneford
Copy link

eugeneford commented Apr 19, 2018

@mixer2, @plasticine, the same in my project. We are using: Karma + Webpack + Istanbul Instrumenter Loader + coverageInstunbulReporter.

We are facing a pretty similar issue. Lets say that we have:

import something from './something'.

const doSomething = () => {
  const a = 50;
  const b = a + 100;
  something(b);
}

export default doSomething;

Test spec would be:

import somethingInjector from 'inject-loader!./something';

describe('something', () => {
  it('should do something', () => {
    const iSomething  = somethingInjector(
      './something': () => console.log('mocked'),
    ).default;

    iSomething();
  })
});

The issue is that coverage report shows that original doSomething() function is completely uncovered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants