From ded9237acce0fa2ea8a7557cd5b4ade60a10ae4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Matte?= Date: Tue, 6 Dec 2022 20:05:29 -0500 Subject: [PATCH] Extract stats creation --- lib/metaltest.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/metaltest.js b/lib/metaltest.js index 7881c16..4a3104e 100644 --- a/lib/metaltest.js +++ b/lib/metaltest.js @@ -11,6 +11,10 @@ const metaltest = (title) => { const testSuccess = [] const testFail = [] + const stats = () => { + return { title, success, fail, total: success + fail, testSuccess, testFail } + } + const runner = (name, fn) => { suite.push({ name, fn }) } @@ -48,11 +52,9 @@ const metaltest = (title) => { } } - const stats = { title, success, fail, total: success + fail, testSuccess, testFail } - for (const test of end) { try { - await test.fn(stats) + await test.fn(stats()) success++ testSuccess.push(test) @@ -66,7 +68,7 @@ const metaltest = (title) => { for (const fn of after) await fn() - notify(reporters, 'end', stats) + notify(reporters, 'end', stats()) return stats }