diff --git a/lib/helper/coverage.js b/lib/helper/coverage.js index 22ae36b..d0e6186 100644 --- a/lib/helper/coverage.js +++ b/lib/helper/coverage.js @@ -30,6 +30,7 @@ module.exports = wd => { let { coverageIgnore = program.coverageIgnore, keys = [], + coverageHandler, } = opts; const tempDir = path.join(cwd, 'coverage', '.temp'); _.mkdir(tempDir); @@ -57,7 +58,11 @@ module.exports = wd => { const coverage = await this.execute(`return window.__coverage__['${keys[i]}']`); if (coverage) { const coverageJSON = JSON.stringify(coverage); - writer.write(`"${keys[i]}":${coverageJSON}`); + let covChunk; + if (coverageHandler) { + covChunk = await coverageHandler(keys[i], coverageJSON); + } + writer.write(covChunk || `"${keys[i]}":${coverageJSON}`); if (i < keys.length - 1) { writer.write(','); } diff --git a/package.json b/package.json index 2efae5a..6b5fb6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "macaca-wd", - "version": "4.3.5", + "version": "4.3.6", "description": "Macaca webdirver API for Node.js", "keywords": [ "macaca",