This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from education/change-output-wording
Fix formatting of output
- Loading branch information
Showing
2 changed files
with
32 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,53 @@ | ||
const { COLORS } = require("./colors"); | ||
const { AggregateResults } = require("./aggregate-results"); | ||
|
||
const {COLORS} = require('./colors') | ||
const {AggregateResults} = require('./aggregate-results') | ||
const {getTestScore, getMaxScoreForTest} = require('./helpers/test-helpers') | ||
|
||
exports.ConsoleResults = function ConsoleResults(runnerResults) { | ||
try { | ||
let grandTotalPassedTests = 0; | ||
let grandTotalTests = 0; | ||
let grandTotalPassedTests = 0 | ||
let grandTotalTests = 0 | ||
|
||
runnerResults.forEach(({ runner, results }, index) => { | ||
runnerResults.forEach(({runner, results}, index) => { | ||
// Fun transition to new runner | ||
const maxScore = getMaxScoreForTest(results) | ||
// const weight = getTestWeight(maxScore, totalMaxScore); | ||
const score = getTestScore(results) | ||
if (index > 0) { | ||
console.log(`${COLORS.magenta}🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀${COLORS.reset}\n`); | ||
console.log(`${COLORS.magenta}🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀${COLORS.reset}\n`) | ||
} | ||
|
||
console.log(`🔄 Processing: ${runner}`); | ||
let passedTests = 0; | ||
const totalTests = results.tests.length; | ||
console.log(`🔄 Processing: ${runner}`) | ||
let passedTests = 0 | ||
const totalTests = results.tests.length | ||
|
||
results.tests.forEach((test) => { | ||
if (test.status === "pass") { | ||
console.log(`${COLORS.green}✅ ${test.name}\n${COLORS.reset}`); | ||
passedTests += 1; | ||
} else if (test.status === "error") { | ||
console.log(`Error: ${test.message || `Failed to run test '${test.name}'`}\n${COLORS.reset}`); | ||
if (test.status === 'pass') { | ||
console.log(`${COLORS.green}✅ ${test.name}${COLORS.reset}`) | ||
passedTests += 1 | ||
} else if (test.status === 'error') { | ||
console.log(`Error: ${test.message || `Failed to run test '${test.name}'`}\n${COLORS.reset}`) | ||
} else { | ||
console.log(`${COLORS.red}❌ ${test.name}\n`); | ||
console.log(`${test.message || ""}\n${COLORS.reset}`); | ||
console.log(`${COLORS.red}❌ ${test.name}\n`) | ||
console.log(`${test.message || ''}\n${COLORS.reset}`) | ||
} | ||
}); | ||
}) | ||
|
||
// Update grand totals | ||
grandTotalPassedTests += passedTests; | ||
grandTotalTests += totalTests; | ||
grandTotalPassedTests += passedTests | ||
grandTotalTests += totalTests | ||
|
||
// Calculate and display points for the current runner | ||
const points = (passedTests / totalTests) * 100; | ||
console.log(`Total points for ${runner}: ${points.toFixed(2)}/100\n`); | ||
}); | ||
console.log(`Total points for ${runner}: ${score.toFixed(2)}/${maxScore}\n`) | ||
}) | ||
|
||
console.log(`${COLORS.magenta}Test runner summary${COLORS.magenta}`) | ||
|
||
// Calculate and display grand total points | ||
const grandTotalPoints = (grandTotalPassedTests / grandTotalTests) * 100; | ||
AggregateResults(runnerResults) | ||
console.log(`${COLORS.cyan}🏆 Grand total points: ${grandTotalPassedTests}/${grandTotalTests}${COLORS.reset}\n`); | ||
console.log( | ||
`${COLORS.cyan}🏆 Grand total tests passed: ${grandTotalPassedTests}/${grandTotalTests}${COLORS.reset}\n`, | ||
) | ||
} catch (error) { | ||
throw new Error(error.message); | ||
throw new Error(error.message) | ||
} | ||
}; | ||
} |