Created
May 26, 2020 12:15
-
-
Save craigtaub/c8cd7fae5e6fbed56d8982c43211a9fc to your computer and use it in GitHub Desktop.
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
// lib/stats-collector.js | |
function createStatsCollector(runner) { | |
var stats = { | |
suites: 0, | |
tests: 0, | |
passes: 0, | |
pending: 0, | |
failures: 0, | |
}; | |
if (!runner) { | |
throw new TypeError("Missing runner argument"); | |
} | |
runner.stats = stats; | |
runner.once(Runner.constants.EVENT_RUN_BEGIN, function () { | |
stats.start = new Date(); | |
}); | |
runner.on(Runner.constants.EVENT_SUITE_BEGIN, function (suite) { | |
suite.root || stats.suites++; | |
}); | |
runner.on(Runner.constants.EVENT_TEST_PASS, function () { | |
stats.passes++; | |
}); | |
runner.on(Runner.constants.EVENT_TEST_FAIL, function () { | |
stats.failures++; | |
}); | |
runner.on(Runner.constants.EVENT_TEST_END, function () { | |
stats.tests++; | |
}); | |
runner.once(Runner.constants.EVENT_RUN_END, function () { | |
stats.end = new Date(); | |
stats.duration = stats.end - stats.start; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment