isparta-loader icon indicating copy to clipboard operation
isparta-loader copied to clipboard

how to show coverage for all the components, even the ones without tests yet

Open cwei-bgl opened this issue 8 years ago • 2 comments

Hi my isparta is working with the following config:

{
  test: /\.(js|jsx)$/,
  include: path.resolve('src/'),
  loader: 'isparta'
}

But the coverage report only shows the components with tests, but not the ones without tests. I want to show all the components. How to do it?

Thanks, Cheng

cwei-bgl avatar Feb 26 '16 00:02 cwei-bgl

It seems you have to include not just the tests in the webpack context, but the files you want covered as well that would be missing coverage.

brianfegan avatar Jun 03 '16 15:06 brianfegan

I managed to do this like so:

in my src/tests.conf.js

// include all `.js` files exept itself and webpack's etnry points
const context = require.context('../src', true, /^((?!main|tests\.conf).)*\.js/);
context.keys().forEach(context);

I have file structure similar to this (tests and code in the same place):

â–¾ src/
  â–¾ someModule/
      spec.js
      index.js
    main.js
    tests.conf.js

kopach avatar Jun 03 '16 22:06 kopach