Closed mrazauskas closed 2 months ago
Yes, it's good idea to provide a option for .addFromDir()
which is just a string type.
Before do that let‘s consider how to name this option?
So currently we already have:
outputDir
- output reports inlcudes raw
reportinputDir
- input multiple raw
reports for merging report To avoid confusing the users, what is name of this option for raw v8 coverage json files?
addFromDir
? - it is a method name, is it OK?rawV8CoverageDir
? - A bit longcoverageDataDir
?dataDir
?What's your idea?
Additional explanation for the different data:
raw v8 coverage data
provide by v8, it includes coverage data and source-map-cache
for all files (intenal modules, node_modules, everything, it could be redundant)
Node.js: Simply use NODE_V8_COVERAGE
or Inspector API
Browser: Playwright or Puppeteer coverage API (without source-map-cache
provided)
CDP API for both Nodejs and Browser
use for add(data)
or addFromDir(data-dir)
MCR
raw report data
it's filtered data (by entryFilter) after added, which is user focused only, it includes coverage data and separated sources/sourcemaps (multiple coverage data but unique sources/sourcemaps)
use for generating all supported reports and also inputDir
for merging report.
all those data cached in cacheDir
to support multi-process mode. (for example Playwright parallelism mode)
What if inputDir
would be able to handle both types of data? The name of inputDir
is so abstract. This can be any supported input data. Feels intuitive.
The input data type could be specified like this:
{
inputDir: ['./v8-coverage', { type: 'v8' }]
}
{
inputDir: ['./raw-coverage-unit', './raw-coverage-e2e', { type: 'raw' }]
}
// 'raw' is the default and can be omitted, so all works just like now
{
inputDir: ['./raw-coverage-unit', './raw-coverage-e2e']
}
I think, the type
must be specified for inputDir
, not for each path. Otherwise config can get too complex to interpret.
Alternatively input data type could be simply specified via some inputType
option:
{
inputDir: './v8-coverage',
inputType: 'v8'
}
Yes, your approach should work, but as you mentioned, it requires an additional specification of type
. I personally think using a new option name might be better.
I prefer to dataDir
Sounds good too. Indeed specifying type is somewhat clumsy.
please try new version 2.9.0
for new option dataDir
Thanks! All works as expected.
Currently
.addFromDir()
is method, but I would like to use it as an option. If that isn’t complicated to implement.For instance,
inputDir
is somewhat similar option, so I though why not to haveaddFromDir
as an option too? AlsocleanCache
orclean
can be used as options or as methods.I had two separate scripts to generate
raw
report and to merge coverage intocodacy
report. Since thecodacy
report was added, I merged both scripts into one. Now looking at the file it seems likeaddFromDir
could be an option too. See this line: https://github.com/tstyche/tstyche/blob/8e16c416dc614226974bf8be29ab884fcf6b51e7/scripts/report-coverage.js#L53