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

Correctly diagnose errors from required reporter module #3596

Closed
4 tasks done
aido179 opened this issue Dec 4, 2018 · 1 comment · Fixed by #4842
Closed
4 tasks done

Correctly diagnose errors from required reporter module #3596

aido179 opened this issue Dec 4, 2018 · 1 comment · Fixed by #4842
Labels
area: reporters involving a specific reporter type: bug a defect, confirmed by a maintainer

Comments

@aido179
Copy link

aido179 commented Dec 4, 2018

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha.

Description

When developing a third party reporter, mocha misdiagnoses an error coming from within the reporter as the reporter module not being found.

Steps to Reproduce

Minimal reproduction

  1. Create a parent project that uses mocha.
  2. Create a custom reporter, that doesn't require mocha anywhere.
  3. Install that reporter in the parent project (in this case, as a local package using the file location).
  4. When mocha requires the reporter, node throws an error. The require works correctly, but mocha erroneously console.warns that the reporter wasn't found.

Expected behavior:

Mocha says that the reporter package caused the error.

Actual behavior:

Mocha erroneously console.warns that the reporter wasn't found.

Reproduces how often: 100%

Versions

Mocha version: 5.2.0 (not installed globally)
Node version: v8.11.1
OS: MacOs High Sierra v10.13.6
Shell: iTerm2 build 3.2.4beta2

Additional Information

As discussed in #3530, initially thought the package was not being required correctly.

@outsideris outsideris added area: reporters involving a specific reporter unconfirmed-bug labels Dec 5, 2018
@plroebuck
Copy link
Contributor

While I can see how a better error message could be helpful, the real bug here is in your reporter depending on missing project dependencies.

@juergba juergba changed the title Correctly diagnose errors from required runner module Correctly diagnose errors from required reporter module Mar 9, 2022
@juergba juergba added type: bug a defect, confirmed by a maintainer and removed unconfirmed-bug labels Mar 9, 2022
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 type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants