Skip to content

Commit

Permalink
Merge pull request #73 from iamando/develop
Browse files Browse the repository at this point in the history
feat: calcute total test effecttued , passed , failed , avg duration, coverage and flaky test
  • Loading branch information
Ando authored May 20, 2024
2 parents ce1b685 + caee1ec commit 4e133fc
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions src/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ const exportJSONReport = (
({ status }: { status: string }) => status,
)

const testCoverage = getCoverage({ results: totalTests })

const avgTestDuration = getAverageDuration({ results: totalTests })

const flakyTestsCount = jsonData.drowser.cases.filter((c) =>
c.month_of_test === month
).map((item) => item.flaky)
Expand All @@ -146,13 +142,37 @@ const exportJSONReport = (
current_month: month,
}

const CombinedTotalTests = [
...jsonData.drowser.cases.flatMap((item) => item.cases),
...results,
]

const CombinedGroupByStatus = Object.groupBy(
totalTests,
({ status }: { status: string }) => status,
)

const CombinedTestCoverage = getCoverage({ results: CombinedTotalTests })

const CombinedAvgTestDuration = getAverageDuration({
results: CombinedTotalTests,
})

const CombinedFlakyTestsCount = jsonData.drowser.cases.map((item) =>
item.flaky
)
.reduce(
(acc, cur) => acc + cur,
0,
)

jsonData.drowser.metrics = {
total_tests: totalTests.length ?? 0,
passing_tests: groupByStatus?.passed?.length ?? 0,
failed_tests: groupByStatus?.failed?.length ?? 0,
test_coverage: testCoverage ?? 0,
avg_test_duration: avgTestDuration ?? 0,
flaky_tests: flakyTestsCount,
total_tests: CombinedTotalTests.length ?? 0,
passing_tests: CombinedGroupByStatus?.passed?.length ?? 0,
failed_tests: CombinedGroupByStatus?.failed?.length ?? 0,
test_coverage: CombinedTestCoverage ?? 0,
avg_test_duration: CombinedAvgTestDuration ?? 0,
flaky_tests: CombinedFlakyTestsCount,
graphs: {
total_tests: [
{
Expand Down

0 comments on commit 4e133fc

Please sign in to comment.