Open
Description
openedon Jan 11, 2021
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) andmocha --version
(Global). We recommend that you not install Mocha globally.
Description
Programmatically using mocha.addFile(file)
and mocha.unloadFiles()
in an ES module context throws MODULE_NOT_FOUND
when mocha.addFile(...)
is called with a relative path.
Wrapping the module resolution logic with path.resolve(...)
resolves this issue by ensuring the path is absolute.
Steps to Reproduce
https://repl.it/@christiantjl/MochaFileUnloader#fails.js
node succeeds.js
shows that an absolute path works without issue, and node fails.js
shows that adding with a relative path throws an error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment