Last active
June 6, 2020 17:42
-
-
Save craigtaub/8c8d2e7580ca8aaff4603f5146ca379c 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
Runner.prototype.runTests = function(callback) { | |
function next() { | |
// grab next test | |
test = tests.shift() | |
// no tests left, run callback running next suite | |
if (!test) callback() | |
// run beforeEach hooks | |
hooks(HOOK_TYPE_BEFORE_EACH, () => { | |
runTest(err => { | |
if (err) { | |
// test failure | |
this.emit(EVENT_TEST_FAIL, test, err) | |
self.emit(EVENT_TEST_END, test) | |
// run after each hook | |
return hooks(HOOK_TYPE_AFTER_EACH, next) | |
} | |
// test pass | |
self.emit(EVENT_TEST_PASS, test) | |
self.emit(EVENT_TEST_END, test) | |
// run after each hook | |
hooks(HOOK_TYPE_AFTER_EACH, next) | |
}) | |
}) | |
} | |
// run next test | |
next() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment