isparta-loader
isparta-loader copied to clipboard
how to show coverage for all the components, even the ones without tests yet
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
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.
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