Skip to content

Commit

Permalink
fix: countflaky result
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma11hewThomas committed Dec 7, 2024
1 parent 6108953 commit 89ab204
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/handlebars/helpers/ctrf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

Expand Down

0 comments on commit 89ab204

Please sign in to comment.