Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implemented Puppeteer to V8 Class #4

Merged
merged 5 commits into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions lib/puppeteer-to-v8.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
class PuppeteerToV8 {
// constructor () {}
}
constructor (coverageInfo) {
this.coverageInfo = coverageInfo
}

setCoverageInfo (coverageInfo) {
this.coverageInfo = coverageInfo
}

module.exports = () => {
return new PuppeteerToV8()
convertCoverage () {
// Iterate through coverage info and create IDs
let id = 0

return this.coverageInfo.map(coverageItem => {
return {
scriptId: id++,
url: coverageItem.url,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once Robert finishes his work, we'll want to store the final path that will be saved to disk rather than the original URL.

I'm fine with landing it without this at the outset, just noting here that we need to update.

functions: { ranges: coverageItem.ranges }
}
})
}
}

module.exports = () => new PuppeteerToV8()
21 changes: 16 additions & 5 deletions test/puppeteer-to-v8.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
/* globals describe, it */
/* globals describe, it, before */

const puppeteerToV8 = require('../lib/puppeteer-to-v8')()
var PuppeteerToV8 = require('../lib/puppeteer-to-v8')()

require('chai').should()

describe('puppeteer-to-v8', () => {
let v8Coverage
const fixture = require('./fixtures/function-coverage-missing')

before(() => {
PuppeteerToV8.setCoverageInfo(fixture)

v8Coverage = PuppeteerToV8.convertCoverage()
})

it('translates ranges into v8 format', () => {
console.info(puppeteerToV8)
// V8 coverage has ranges on a functions object, so check for that
v8Coverage[0].functions.ranges.should.eql(fixture[0].ranges)
})

// use mkdirp:
Expand All @@ -17,8 +27,9 @@ describe('puppeteer-to-v8', () => {

// look at the uuid library:
// uuid.v4()
it('generates scriptID', () => {

it('generates scriptId', () => {
// Ensures that the scriptId is of type 'number'
(typeof v8Coverage[0].scriptId).should.eql('number')
})

// for this test case, make sure we cover what happens
Expand Down