|
|
@ -36,6 +36,7 @@ function Test(title, fn, contextRef, report) { |
|
|
|
this.sync = true; |
|
|
|
this.contextRef = contextRef; |
|
|
|
this.report = report; |
|
|
|
this.threwSync = false; |
|
|
|
|
|
|
|
// TODO(jamestalmage): make this an optional constructor arg instead of having Runner set it after the fact.
|
|
|
|
// metadata should just always exist, otherwise it requires a bunch of ugly checks all over the place.
|
|
|
@ -95,6 +96,7 @@ Test.prototype._run = function () { |
|
|
|
try { |
|
|
|
ret = this.fn(this._publicApi()); |
|
|
|
} catch (err) { |
|
|
|
this.threwSync = true; |
|
|
|
if (err instanceof Error) { |
|
|
|
this._setAssertError(err); |
|
|
|
} else { |
|
|
@ -176,7 +178,7 @@ Test.prototype.run = function () { |
|
|
|
return this.promise().promise; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.metadata.callback) { |
|
|
|
if (this.metadata.callback && !this.threwSync) { |
|
|
|
return this.promise().promise; |
|
|
|
} |
|
|
|
|
|
|
@ -214,7 +216,8 @@ Test.prototype._end = function (err) { |
|
|
|
} |
|
|
|
|
|
|
|
if (this.endCalled) { |
|
|
|
throw new Error('.end() called more than once'); |
|
|
|
this._setAssertError(new Error('.end() called more than once')); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.endCalled = true; |
|
|
@ -239,7 +242,7 @@ Test.prototype.exit = function () { |
|
|
|
|
|
|
|
this._checkPlanCount(); |
|
|
|
|
|
|
|
if (this.sync) { |
|
|
|
if (this.sync || this.threwSync) { |
|
|
|
self.duration = globals.now() - self._timeStart; |
|
|
|
globals.clearTimeout(self._timeout); |
|
|
|
|
|
|
|