fix: handle case of invalid package.json with no explicit config#5198
fix: handle case of invalid package.json with no explicit config#5198JoshuaKGoldberg merged 5 commits intomochajs:mainfrom
Conversation
Since `readFileSync` is only stubbed `onFirstCall` we get a different answer the second time around which is probably Not What You Want. But also we *already checked that config = false*. So you could just remove this test, it does nothing useful.
|
(signed the CLA!) |
|
Thanks for the PR! Gave some feedback |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
LGTM, nicely done! Agreed with the strategy inside 👍 thanks!
Since @voxpelli was looking at this before, leaving open for re-review.
|
Btw @dhdaines, just a heads up, the |
Ohhh! Thank you, I have been wondering about that for ages now! (suppose I should have RTF the Markdown manual...) |
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
|
Ah, I suspect that the more obviously invalid JSON will break the too-specific assertion in the test... will fix it in a second. |
Done! |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
🙌 Looks great to me! Just waiting on @voxpelli. Thanks!
…hajs#5198) * fix: report syntax errors in package.json (fixes: mochajs#5141) * fix(tests): incorrect test (should use existing result) Since `readFileSync` is only stubbed `onFirstCall` we get a different answer the second time around which is probably Not What You Want. But also we *already checked that config = false*. So you could just remove this test, it does nothing useful. * fix: separate read and parse errors * fix: clarify invalid JSON Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com> * fix(test): expect only a SyntaxError nothing else --------- Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
PR Checklist
package.jsonsection #5141status: accepting prsOverview
Handle the corner case which can happen if:
package.jsonwhich npm was happy withmochaconfiguration inside yourpackage.jsonnpm testyou ranmochadirectly (withnpxor justmocha.js)As detailed here: https://github.com/dhdaines/mocha-5141