-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into output-files
- Loading branch information
Showing
3 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,34 @@ | ||
class PuppeteerToV8 { | ||
// constructor () {} | ||
} | ||
constructor (coverageInfo) { | ||
this.coverageInfo = coverageInfo | ||
} | ||
|
||
setCoverageInfo (coverageInfo) { | ||
this.coverageInfo = coverageInfo | ||
} | ||
|
||
convertCoverage () { | ||
// Iterate through coverage info and create IDs | ||
let id = 0 | ||
|
||
module.exports = () => { | ||
return new PuppeteerToV8() | ||
return this.coverageInfo.map(coverageItem => { | ||
return { | ||
scriptId: id++, | ||
url: coverageItem.url, | ||
functions: [{ ranges: coverageItem.ranges.map(this.convertRange) }] | ||
} | ||
}) | ||
} | ||
|
||
// Takes in a Puppeteer range object with start and end properties and | ||
// converts it to a V8 range with startOffset, endOffset, and count properties | ||
convertRange (range) { | ||
return { | ||
startOffset: range.start, | ||
endOffset: range.end, | ||
count: 1 | ||
} | ||
} | ||
} | ||
|
||
module.exports = (coverageInfo) => new PuppeteerToV8(coverageInfo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters