Exclude Files in Coverage Config
There seems to be some issue with coverageConfig.exclude. It is part of the finalConfig which is passed out of parseConfig.js, but does not seem to exclude files from the coverage report (reporter: json).
If I provide this configuration, I still get files in __wds-outside-root__ in my coverage report.
export default ({
nodeResolve: true,
coverageConfig: {
report: true,
reportDir: 'coverage',
exclude: ['**/node_modules/**/*', '**/web_modules/**/*', '**/__wds-outside-root__/**/*'],
reporters: ['text-summary', 'json-summary']
}
});
We have many components and want to collect coverage on each independently.
I did some debugging and I see that __wds-outside-root__ is properly excluded. Do you have some reproduction we could look at?
I'm having the same issue. How do you exclude node_modules from the coverage output?
Ive tried multiple variants of excluding node_modules from the config. The below is a kitchen sink approach that also doesn't work...
export default {
rootDir: '.',
nodeResolve: true,
files: [
'src/**/*.test.ts',
'!node_modules/**/*',
'!**/node_modules/**/*'
],
coverage: true,
coverageConfig: {
report: true,
reportDir: 'coverage',
exclude: [
'node_modules/**/*',
'**/node_modules/**/*',
'web_modules/**/*',
'**/web_modules/**/*',
'**/__wds-outside-root__/**/*'
],
}
}
I use '**/node_modules/**',...
Thanks @Westbrook . Tried that too, i must have something else wrong.
I had the same problem and randomly found a solution:
coverageConfig: {
include: ['**']
}
Any luck from this?
My web-test-runner.config.js is:
const { esbuildPlugin } = require('@web/dev-server-esbuild');
module.exports = {
files: [
'./src/**/*.test.ts',
'!**/node_modules/**/*',
],
nodeResolve: true,
coverage: true,
coverageConfig: {
exclude: [
'node_modules/**',
'**/node_modules/**',
],
},
plugins: [
esbuildPlugin({ ts: true }),
],
};
I still see node_modules/.pnpm/@open-wc+testing at coverage/lcov-report/index.html.
Already resolved,
I modified my config to include @dominikfryc suggestion, as follow:
const { esbuildPlugin } = require('@web/dev-server-esbuild');
module.exports = {
files: [
'./src/**/*.test.ts',
],
nodeResolve: true,
coverage: true,
coverageConfig: {
include: ['**'],
exclude: ['**/node_modules/**'],
},
plugins: [
esbuildPlugin({ ts: true }),
],
};
And it works, now I only see my src files.