@web/test-runner-chrome
Advanced tools
Comparing version 0.5.1 to 0.5.2
# @web/test-runner-chrome | ||
## 0.5.2 | ||
### Patch Changes | ||
- 5ab18d8: feat(test-runner-core): batch v8 test coverage | ||
## 0.5.1 | ||
@@ -4,0 +10,0 @@ |
@@ -7,2 +7,17 @@ "use strict"; | ||
const findExecutablePath_1 = require("./findExecutablePath"); | ||
async function getPageCoverage(config, testFiles, page) { | ||
var _a, _b, _c, _d; | ||
// TODO: this is using a private puppeteer API to grab v8 test coverage, this can be removed | ||
// when https://github.com/puppeteer/puppeteer/issues/2136 is resolved | ||
const response = (await page._client.send('Profiler.takePreciseCoverage')); | ||
// puppeteer already has the script sources available, remove this when above issue is resolved | ||
const scriptSources = (_c = (_b = (_a = page) === null || _a === void 0 ? void 0 : _a.coverage) === null || _b === void 0 ? void 0 : _b._jsCoverage) === null || _c === void 0 ? void 0 : _c._scriptSources; | ||
const v8Coverage = response.result | ||
// remove puppeteer specific scripts | ||
.filter(r => r.url && r.url !== '__puppeteer_evaluation_script__') | ||
// attach source code | ||
.map(r => (Object.assign(Object.assign({}, r), { source: scriptSources.get(r.scriptId) }))); | ||
await ((_d = page.coverage) === null || _d === void 0 ? void 0 : _d.stopJSCoverage()); | ||
return await test_runner_coverage_v8_1.v8ToIstanbul(config, testFiles, v8Coverage); | ||
} | ||
function chromeLauncher({ executablePath: customExecutablePath, puppeteer, args, } = {}) { | ||
@@ -46,2 +61,5 @@ const executablePath = customExecutablePath !== null && customExecutablePath !== void 0 ? customExecutablePath : findExecutablePath_1.findExecutablePath(); | ||
page = await browser.newPage(); | ||
if (config.coverage) { | ||
await page.coverage.startJSCoverage(); | ||
} | ||
} | ||
@@ -52,5 +70,2 @@ else { | ||
activePages.set(session.id, page); | ||
if (config.coverage) { | ||
await page.coverage.startJSCoverage(); | ||
} | ||
await page.goto(url); | ||
@@ -65,26 +80,4 @@ }, | ||
}, | ||
async getTestCoverage(session) { | ||
var _a, _b, _c, _d; | ||
const page = activePages.get(session.id); | ||
if (!page) { | ||
throw new Error(`No page for session ${session.id}`); | ||
} | ||
let istanbulCoverage = undefined; | ||
if (config.coverage) { | ||
// TODO: this is using a private puppeteer API to grab v8 test coverage, this can be removed | ||
// when https://github.com/puppeteer/puppeteer/issues/2136 is resolved | ||
const response = (await page._client.send('Profiler.takePreciseCoverage')); | ||
// puppeteer already has the script sources available, remove this when above issue is resolved | ||
const scriptSources = (_c = (_b = (_a = page) === null || _a === void 0 ? void 0 : _a.coverage) === null || _b === void 0 ? void 0 : _b._jsCoverage) === null || _c === void 0 ? void 0 : _c._scriptSources; | ||
const v8Coverage = response.result | ||
// remove puppeteer specific scripts | ||
.filter(r => r.url && r.url !== '__puppeteer_evaluation_script__') | ||
// attach source code | ||
.map(r => (Object.assign(Object.assign({}, r), { source: scriptSources.get(r.scriptId) }))); | ||
await ((_d = page.coverage) === null || _d === void 0 ? void 0 : _d.stopJSCoverage()); | ||
istanbulCoverage = await test_runner_coverage_v8_1.v8ToIstanbul(config, testFiles, v8Coverage); | ||
} | ||
activePages.delete(session.id); | ||
inactivePages.push(page); | ||
return istanbulCoverage; | ||
getTestCoverage() { | ||
return Promise.all(inactivePages.map(page => getPageCoverage(config, testFiles, page))); | ||
}, | ||
@@ -91,0 +84,0 @@ async startDebugSession(session, url) { |
{ | ||
"name": "@web/test-runner-chrome", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"publishConfig": { | ||
@@ -46,4 +46,4 @@ "access": "public" | ||
"@web/test-runner-mocha": "^0.2.5", | ||
"@web/test-runner-server": "^0.5.6" | ||
"@web/test-runner-server": "^0.5.7" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69148
14670
145