From 89ab204265e67f230f42e256de9559640898d892 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Date: Sat, 7 Dec 2024 23:41:02 +0000 Subject: [PATCH] fix: countflaky result --- src/handlebars/helpers/ctrf.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/handlebars/helpers/ctrf.ts b/src/handlebars/helpers/ctrf.ts index 9f1664d6..4285457e 100644 --- a/src/handlebars/helpers/ctrf.ts +++ b/src/handlebars/helpers/ctrf.ts @@ -50,20 +50,9 @@ export function moreThanHelper(): void { * @returns {number} The number of flaky tests. */ export function countFlakyHelper(): void { - Handlebars.registerHelper('countFlaky', (tests: unknown) => { - if (!Array.isArray(tests)) { - throw new Error('Invalid input to countFlaky: tests must be an array') - } - - const flakyTests = tests.filter( - (test): test is CtrfTest => - typeof test === 'object' && - test !== null && - 'flaky' in test && - typeof (test as CtrfTest).flaky === 'boolean' - ) - - return flakyTests.length + Handlebars.registerHelper('countFlaky', tests => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access + return tests.filter((test: { flaky: boolean }) => test.flaky).length }) }