Open joyfulelement opened 8 years ago
I've the same issue, will this get any attention?
I spent the few day looking into this and here's my solution using babel-plugin-istanbul
and babel 7. https://github.com/karma-runner/karma-coverage/issues/125#issuecomment-385261963
babel-plugin-__coverage__
is no longer maintained so it's probably a good idea to switch to babel-plugin-istanbul
anyway.
Hi there. For anyone still interested in this topic, Here is a tool, which helps to add untested files to coverage report quite easy. https://github.com/kopach/karma-sabarivka-reporter Karma has limitation in detecting all source files, in case we pass only 1 file as starting point to our tests. E.g.:
files: [
'tests/EntryPoint.js'
],
This tool overcomes such limitation.
What's the benefit of adding another tool when it's all about karma lacking to see all entry files of your project? Simply add bogus tests for those entry files should be sufficient, e.g. when in an Angular project, test your AppModule for being truthy.
import {AppModule} from './app.module';
describe('App module', () => {
it('exists', () => {
expect(AppModule).toBeTruthy();
})
})
This works well in our case.
By supplying the
includeAllSources: true
flag incoverageReporter
ofkarma.conf.js
, the generated output doesn't include the untested files with the following setup. This maybe related to #192 , but with the different instrumenterbabel-plugin-__coverage__
being used here.Does anyone had similar experience for how to include untested files in the result and manage to get it to work with
babel-plugin-__coverage__
? ThanksHere is the
.babelrc
Here is the lineup of the libraries in
package.json
:Here is the code snippet from
karma.conf.js
: