🐛 Bug: Internal errors in reporter for pending tests incorrectly labelled #2220
Labels
area: reporters
involving a specific reporter
status: wontfix
typically a feature which won't be added, or a "bug" which is actually intended behavior
type: bug
a defect, confirmed by a maintainer
In the process of digging into #2211 (e.g. as discussed in this comment), I discovered that failures when processing a test that was not run (e.g. incorrect pending checks in a reporter, although it seems those particular errors have been fixed in master) will be reported as belonging to a previously run test or hook. To see, simply take master, add an error to a reporter's processing of a pending test result, and run a suite with pending tests after either non-pending tests or a before or beforeEach hook that will run.
I've narrowed it down to the fact that the
currentRunnable
variable in mocha/lib/runner.js is assigned whenever a hook is found and whenever a test is run, but not if a test is pending. I believe there are a couple possible fixes:self.currentRunnable = self.test;
on line 527 of runner.js, addself.currentRunnable = test;
at line 509 (well, between what's currently lines 508 and 510; there should probably be a couple newlines on either side of the added line), so that errors occurring during processing of pending tests are reported with that test's description rather than with the most recently run test or hook's description. (currentRunnable
isn't used except in uncaught error reporting, so this shouldn't have any unwanted side effects.)currentRunnable
.currentRunnable
for the case of pending tests, but also prepend "Mocha internal error processing: " to the name reported when a Mocha internal location is found for the error's origin.The text was updated successfully, but these errors were encountered: