From fc319d6a4fa98df4191db5d20ab9a7b31cc6ff65 Mon Sep 17 00:00:00 2001 From: Richie McColl Date: Thu, 23 Feb 2023 09:15:37 +0000 Subject: [PATCH] doc: add test:coverage event to custom reporter examples PR-URL: https://github.com/nodejs/node/pull/46752 Reviewed-By: Colin Ihrig Reviewed-By: Moshe Atlow Reviewed-By: Luigi Pinca --- doc/api/test.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/api/test.md b/doc/api/test.md index e3eca690246969..90a91dd2016875 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -555,6 +555,11 @@ const customReporter = new Transform({ case 'test:diagnostic': callback(null, event.data.message); break; + case 'test:coverage': { + const { totalLineCount } = event.data.summary.totals; + callback(null, `total line count: ${totalLineCount}\n`); + break; + } } }, }); @@ -584,6 +589,11 @@ const customReporter = new Transform({ case 'test:diagnostic': callback(null, event.data.message); break; + case 'test:coverage': { + const { totalLineCount } = event.data.summary.totals; + callback(null, `total line count: ${totalLineCount}\n`); + break; + } } }, }); @@ -612,6 +622,11 @@ export default async function * customReporter(source) { case 'test:diagnostic': yield `${event.data.message}\n`; break; + case 'test:coverage': { + const { totalLineCount } = event.data.summary.totals; + yield `total line count: ${totalLineCount}\n`; + break; + } } } } @@ -636,6 +651,11 @@ module.exports = async function * customReporter(source) { case 'test:diagnostic': yield `${event.data.message}\n`; break; + case 'test:coverage': { + const { totalLineCount } = event.data.summary.totals; + yield `total line count: ${totalLineCount}\n`; + break; + } } } };