-
Notifications
You must be signed in to change notification settings - Fork 176
Description
Repro: https://github.com/dboune/lab-chunks
When running lab with --sourcemaps --transform node_modules/lab-transform-typescript in order to run tests written in typescript, if sourcemap "chunks" are encountered, the html reporter (-r html -o coverage.html) will error.
lab-chunks/node_modules/lab/lib/reporters/html.js:210
const target = descriptors[originalFilename].source[originalLine];
^
TypeError: Cannot read property 'source' of undefined
at Object.keys.forEach (lab-chunks/node_modules/lab/lib/reporters/html.js:210:65)
Sourcemap chunks appear to occur when code branches.
Poking around I found that a variable descriptors is empty, but chunk processing in the html reporter appears to require it.
The following callback never runs (sourceContents is empty when SourceNode is processing): https://github.com/hapijs/lab/blob/v14.3.0/lib/reporters/html.js#L151
I was able to get the html reporter to complete by wrapping the entire chunks processing block in a test to see if descriptors had anything in it. I do not know whether or not this is an appropriate fix.
if (Object.keys(descriptors).length) {
// Now maps coverage information to original files
Object.keys(file.source).forEach((generatedLine) => {Hopefully I am not reporting my own mistake :)
Thank you!