-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
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 forgot to npm install a library, and tried to test with Mocha. I expected an error about the missing module.
Actual
The error claims the missing module is a cyclical import. It is not cyclical, it is just missing
Minimal, Reproducible Example
Here is a gist that reproduces the problem using bash: https://gist.github.com/MaxKessler5/9d53a143df67ce1cd4dff9e9f03d2db4
The contents:
npm init -y
sed -i 's/"type": "commonjs"/"type": "module"/' package.json
echo "// Entry point for the application" > index.js
echo "import { cloneDeep } from "lodash-es";" >> index.js
sed -i 's/"test":.*/"test": "mocha"/' package.json
npm install mocha
mkdir test
echo "import "../index.js";" > test/test.js
npm test > output.txt
Versions
$ npx mocha --version
11.1.0
node_modules/.bin/mocha --version
(I'm on windows, not sure how to do this one)
node --version
v22.12.0
Additional Info
No response