Summarise a test report
intermediate Automation utilities Challenge 9 of 18
Write summarizeReport(report) for a JSON test report shaped like this:
{ "suites": [ { "name": "login", "tests": [ { "title": "valid user", "status": "passed", "durationMs": 900 } ] } ] }
status is one of passed, failed or skipped. Return { total, passed, failed, skipped, passRate, slowest }.
Requirements
- Count tests across all suites.
passRateis the percentage of executed tests (passed plus failed) that passed, rounded to one decimal place, for example66.7. It isnullwhen no test was executed.slowestis{ title, suite, durationMs }for the executed test with the highestdurationMs, ornullwhen none ran. Skipped tests are never the slowest.- Never return
NaN.
Expected output
{ total: 5, passed: 3, failed: 1, skipped: 1, passRate: 75, slowest: { title: 'pays by card', suite: 'checkout', durationMs: 4200 } }
Test cases (6)
- ○counts totals across all suites
- ○pass rate excludes skipped tests
- ○finds the slowest test and its suite
- ○skipped tests are never the slowest
- ○empty report does not produce NaN
- ○only skipped tests gives a null pass rate
solution.jsExecutes in your browser
Ctrl/⌘ + Enter to run tests · your code is saved in this browser
Results
Run the tests to see results here.