uncaughtException: fix when current test is pending #4083
Merged
+86
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
output with exitCode: 0
Description of the Change
Runner#uncaught
:per default Mocha tries to map
uncaughtException
's to the correct test case, to recover and keep therunner
working. This is quite simple with synchronous tests, in an async scenario (by design or by coder's mistake) it's done on a "best effort" basis.Currently the user has no possibility to escape this recovery effort, not even with the
--allow-uncaught
option. Now--allow-uncaught
throws an error and exit Mocha's process.current test is pending: when an
uncaughtException
bubbles up, we retrospectively label the pending test as failed, then keep the runner going. That way theexitCode
will be >0.When an
uncaughtException
bubbles up we can't clearly determine its origin. I suppose our recovery process is responsible for a few weird bugs, eg. number of executed tests is varying when rerun, errors are swallowed (reporters?) or non-existing hooks throw errors. So its important to have an effective mean to throw and exit when tracing fuzzy errors.Recovery process, when current test is:
uncaughtException
, runner keeps goingApplicable issues
closes #3938