From 565ad3f0e1c5458daecb450cbc62c692b7fa0be0 Mon Sep 17 00:00:00 2001 From: SmartBear <471110230@qq.com> Date: Tue, 30 Jan 2024 10:55:43 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20coverage=E6=94=AF=E6=8C=81=E5=8A=A0?= =?UTF-8?q?=E5=B7=A5=20(#123)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/helper/coverage.js | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) 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",