-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
unhelpful error messages while using asynch in before() #4850
Comments
@jric I understand You have two mistakes in your test sample:
I agree this error message is suboptimal, it's a known Node issue. We already tried to improve the information, see #4557, it's a hack until Node has fixed the issue permanently. |
I certainly am not suggesting an ESM tutorial in the mocha docs, but I appreciate that I may ask too much, @juergba. At least the next unsuspecting soul may find this ticket in a keyword search and save themselves some time. ESM is recommended by some popular projects and usage will increase over time. I think this confusion is likely to happen with increasing frequency before it gets resolved by the Node community. Thank you for considering my proposal and guiding me away from ESM for now. |
Mocha has been supporting Node's native ESM since 2020-02-26, with very few issues reported. |
Prerequisites
faq
labelnode_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
Being a noob with ESM, I did not realize that I could not simply follow the documentation at the top of https://mochajs.org/. After following the "prerequisites" steps for filing a ticket, I found my error and eventually found https://mochajs.org/#nodejs-native-esm-support. However, I believe I had some unneeded frustration. The error message I got was:
for which I found very little actionable information, mostly in this ticket: nodejs/node#49441
Steps to Reproduce
create
package.json
with"type"="module"
create this test file, and run it with
mocha
Expected behavior:
I expect to see an error, such as I get when I remove the "await" from the test code above.
As another simple fix, I expect to see a qualification at the top of the documentation that specifies that the sample code is only for using the common module system, and it could link down to the alternate code for using ESM.
Actual behavior:
As mentioned above, I dutifully follow the sample code and get a very cryptic error.
Reproduces how often: 100%
Versions
mocha --version
andnode_modules/.bin/mocha --version
:node --version
:macOS Monterey 12.2.1
64 bit
zsh
Additional Information
N/A
The text was updated successfully, but these errors were encountered: