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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug: mocha fails silently on invalid package.json section #5141

Open
4 tasks done
dhdaines opened this issue May 2, 2024 · 0 comments
Open
4 tasks done

馃悰 Bug: mocha fails silently on invalid package.json section #5141

dhdaines opened this issue May 2, 2024 · 0 comments
Labels
status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer

Comments

@dhdaines
Copy link

dhdaines commented May 2, 2024

Bug Report Checklist

  • I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
  • I have searched for related issues and issues with the faq label, but none matched my issue.
  • I have '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, my usage of Mocha, or Mocha itself.
  • I want to provide a PR to resolve this

Expected

I made an error in my package.json (an extra comma) because JSON is a bad format for configuration files ;-) like this:

"mocha": {
    "spec": "./*.spec.js",
}

I expected mocha to give me an error, ideally a bit friendlier than the one from npm, but something like that:

$ npm install
npm ERR! code EJSONPARSE
...
npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.

Actual

Mocha just failed as if I hadn't configured it at all. This was very confusing:

$ npx mocha
Error: No test files found: "test"

Minimal, Reproducible Example

See "expected" above but basically:

npm install -D mocha

then add the offending section to package.json, then create foo.spec.js, then try to run mocha.

Versions

10.4.0 10.4.0 v20.11.0

Additional Info

I could definitely provide a PR if you could direct me to the appropriate place in the code (with which I am not familiar)

@dhdaines dhdaines added status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant