Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: Internal errors in reporter for pending tests incorrectly labelled #2220

Closed
ScottFreeCode opened this issue Apr 24, 2016 · 1 comment
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

Comments

@ScottFreeCode
Copy link
Contributor

ScottFreeCode commented Apr 24, 2016

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:

  • Remove self.currentRunnable = self.test; on line 527 of runner.js, add self.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.)
  • Detect and specially label errors originating in Mocha code rather than test code; for instance, wherever it's getting the stack location of the error in the case of internal errors, also override the name associated with the error to something like "Mocha internal error" instead of the name of the currentRunnable.
  • Both -- fix the 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.
@drazisil drazisil added type: bug a defect, confirmed by a maintainer area: reporters involving a specific reporter labels Mar 30, 2017
@JoshuaKGoldberg JoshuaKGoldberg changed the title Internal errors in reporter for pending tests incorrectly labelled 🐛 Bug: Internal errors in reporter for pending tests incorrectly labelled Dec 27, 2023
@JoshuaKGoldberg
Copy link
Member

This hasn't had interactions since 2017. Closing out as stale/wontfix - but if someone has a real repro of the issue, please do post so we can re-open. Cheers!

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2024
@JoshuaKGoldberg JoshuaKGoldberg added the status: wontfix typically a feature which won't be added, or a "bug" which is actually intended behavior label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants