test-runner
test-runner copied to clipboard
Coverage report from all files
It looks like to coverage generated with this plugin comes only from files that were tested. Is there a way to have a coverage report from the whole project (include files that were not touched by storybook)?
I'm using https://storybook.js.org/addons/@storybook/test-runner to run tests and collect coverage
I believe (untested) that you can configure the Istanbul to collect coverage from all files with all
flag, which you can set through the addon options.istanbul
.
module.exports = {
addons: [
{
name: '@storybook/addon-coverage',
options: {
istanbul: {
all: true
}
}
}
],
};
See the documentation of istanbul/nyc for Selecting files for coverage.
The options passed to the addon as options.istanbul
are all appended to the istanbul plugin, so you are be able to configure istanbul through the options, only the options are enhanced with the addon specific configs, that might conflict with yours so if the all
will not work, try to inspect the source code a little bit more.
https://github.com/storybookjs/addon-coverage/blob/bfab9eacfaee79ba73dae3f6f878c814f3593126/src/preset.ts#L38
I believe (untested) that you can configure the Istanbul to collect coverage from all files with all flag
I might be wrong, but I think this won't work for the cases where files are not imported (directly or otherwise) by any story. It would be nice to be able to flag such files as having 0 coverage.
all
flag did not work and as @nathanpower said, I was not able to "trick" the coverage to count files that are not imported into any story. And what I need is exactly to report those files at 0 coverage
I don't think this issue belongs to @storybook/addon-coverage
, but instead to https://github.com/storybookjs/test-runner. This plugin only instruments the code. It would be the task of the test-runner, though, to deliver a coverage report for all files. WDYT @yannbf
I don't think this issue belongs to
@storybook/addon-coverage
, but instead to storybookjs/test-runner. This plugin only instruments the code. It would be the task of the test-runner, though, to deliver a coverage report for all files. WDYT @yannbf
Great point. Moved!