Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigtaub/8c8d2e7580ca8aaff4603f5146ca379c to your computer and use it in GitHub Desktop.
Save craigtaub/8c8d2e7580ca8aaff4603f5146ca379c to your computer and use it in GitHub Desktop.
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