-
-
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 add-documentation
- Loading branch information
Showing
7 changed files
with
100 additions
and
26 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const fs = require('fs') | ||
const v8toIstanbul = require('v8-to-istanbul') | ||
const OutputFiles = require('./output-files') | ||
const PuppeteerToV8 = require('./puppeteer-to-v8') | ||
|
||
class PuppeteerToIstanbul { | ||
constructor (coverageInfo) { | ||
this.coverageInfo = coverageInfo | ||
this.puppeteerToConverter = OutputFiles(coverageInfo).getTransformedCoverage() | ||
this.puppeteerToV8Info = PuppeteerToV8(this.puppeteerToConverter).convertCoverage() | ||
} | ||
|
||
setCoverageInfo (coverageInfo) { | ||
this.coverageInfo = coverageInfo | ||
} | ||
|
||
writeIstanbulFormat () { | ||
// TODO: We should iterate through each file based on the coverage info, and then convert to Istanbul here | ||
// console.log(this.puppeteerToV8Info) | ||
|
||
var fullJson = {} | ||
|
||
this.puppeteerToV8Info.forEach(jsFile => { | ||
const script = v8toIstanbul(jsFile.url) | ||
script.applyCoverage(jsFile.functions) | ||
|
||
let istanbulCoverage = script.toIstanbul() | ||
let keys = Object.keys(istanbulCoverage) | ||
|
||
fullJson[keys[0]] = istanbulCoverage[keys[0]] | ||
}) | ||
|
||
// const script = v8toIstanbul(this.puppeteerToV8Info[0].url) | ||
// script.applyCoverage(this.puppeteerToV8Info[0].functions) | ||
fs.writeFileSync('./.nyc_output/out.json', JSON.stringify(fullJson), 'utf8') | ||
} | ||
} | ||
|
||
module.exports = function (coverageInfo) { | ||
return new PuppeteerToIstanbul(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const args = require('yargs').demandCommand(1).argv | ||
const coverageInfo = require(args._[0]) | ||
|
||
const PuppeteerToIstanbul = require('./lib/puppeteer-to-istanbul') | ||
|
||
const pti = PuppeteerToIstanbul(coverageInfo) | ||
pti.writeIstanbulFormat() |
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,38 +1,38 @@ | ||
[ | ||
{ | ||
"url": "file:///C:/istanbul-puppeteer/puppeteer-to-istanbul/test/sample_js/function-coverage-100.js", | ||
"url": "file:////Users/benjamincoe/bcoe/puppeteer-to-istanbul/test/sample_js/function-coverage-100.js", | ||
"ranges": [ | ||
{ | ||
"start": 0, | ||
"end": 47 | ||
"end": 46 | ||
}, | ||
{ | ||
"start": 49, | ||
"end": 90 | ||
"start": 47, | ||
"end": 85 | ||
}, | ||
{ | ||
"start": 92, | ||
"end": 112 | ||
"start": 86, | ||
"end": 102 | ||
} | ||
], | ||
"text": "function a (num1, num2) {\r\n return num1 + num2\r\n}\r\n\r\nfunction b (num) {\r\n return num + 1\r\n}\r\n\r\na(1, 2)\r\nb(3)\r\n" | ||
"text": "function a (num1, num2) {\n return num1 + num2\n}\n\nfunction b (num) {\n return num + 1\n}\n\na(1, 2)\nb(3)\n" | ||
}, | ||
{ | ||
"url": "file:///C:/istanbul-puppeteer/puppeteer-to-istanbul/test/sample_js/function-coverage-100.js", | ||
"url": "file:////Users/benjamincoe/bcoe/puppeteer-to-istanbul/test/sample_js/function-coverage-100.js", | ||
"ranges": [ | ||
{ | ||
"start": 0, | ||
"end": 47 | ||
"end": 46 | ||
}, | ||
{ | ||
"start": 49, | ||
"end": 90 | ||
"start": 47, | ||
"end": 85 | ||
}, | ||
{ | ||
"start": 92, | ||
"end": 112 | ||
"start": 86, | ||
"end": 102 | ||
} | ||
], | ||
"text": "function a (num1, num2) {\r\n return num1 + num2\r\n}\r\n\r\nfunction b (num) {\r\n return num + 1\r\n}\r\n\r\na(1, 2)\r\nb(3)\r\n" | ||
"text": "function a (num1, num2) {\n return num1 + num2\n}\n\nfunction b (num) {\n return num + 1\n}\n\na(1, 2)\nb(3)\n" | ||
} | ||
] | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// /* globals describe, it, before */ | ||
|
||
// var PuppeteerToIstanbul = require('../lib/puppeteer-to-istanbul')() | ||
|
||
// require('chai').should() | ||
|
||
// describe('puppeteer-to-istanbul', () => { | ||
|
||
// const fixture = require('./fixtures/function-coverage-missing.json') | ||
|
||
// before(() => { | ||
|
||
// }) | ||
|
||
// it('translates ranges into lines for istanbul', () => { | ||
|
||
// }) | ||
|
||
// }) |