-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Description
Prerequisites
- Checked that your issue hasn't already been filed by cross-referencing issues with the
faqlabel - 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
.js config loading with --config does not handle relative paths correctly, because it calls require() with a relative path.
Here's the problem: https://github.com/mochajs/mocha/blob/master/lib/cli/config.js#L38
Steps to Reproduce
cd to an empty directory. touch foo.js
mocha --config foo.js
Expected behavior: [What you expect to happen]
mocha loads config from foo.js
Actual behavior: [What actually happens]
/c/Users/cspotcode/Documents/Personal-dev/@mochajs/mocha/lib/cli/config.js:64
throw new Error(`failed to parse ${filepath}: ${err}`);
^
Error: failed to parse foobar.js: Error: Cannot find module 'foo.js'
Reproduces how often: [What percentage of the time does it reproduce?]
All the time
Versions
Mocha 6.0.2
WSL WLinux bash
Additional Information
Issue #3818
Metadata
Metadata
Assignees
Labels
type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer