Skip to content
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

Improve default resolution of mocha.opts #3612

Closed
1 task done
paulmelnikow opened this issue Dec 13, 2018 · 3 comments
Closed
1 task done

Improve default resolution of mocha.opts #3612

paulmelnikow opened this issue Dec 13, 2018 · 3 comments
Labels
type: feature enhancement proposal

Comments

@paulmelnikow
Copy link

Prerequisites

Description

Mocha looks for mocha.opts in test/mocha.opts. Ref: #1275 (comment)

Many projects keep tests next to the code they're testing, which means there's no test/ directory and so unless that test/ folder is created especially for this config file, there's no place that mocha.opts will be read by default.

#1277 provides an alternative here. You can put mocha.opts wherever you want, e.g. alongside package.json, and specify --opts mocha.opts. However the package.json I'm working with has 11 different mocha invocations. I can add --opts mocha.opts to each one, though it's inconvenient and makes these invocations more difficult to read.

It would be a usability improvement to default to searching for mocha.opts alongside the package.json in addition to looking in test/mocha.opts.

Steps to Reproduce

  1. Set options in mocha.opts alongside package.json e.g. --reporter mocha-env-reporter
  2. Run mocha

Expected behavior: The reporter is loaded.

Actual behavior: The reporter is not loaded.

Reproduces how often: Always.

Additional Information

If both files exist, probably it makes sense to print a warning and use test/mocha.opts, for compatibility with the old behavior.

@craigtaub
Copy link
Contributor

craigtaub commented Dec 13, 2018

Hey
So in version 6 we have changed how options are loaded (see https://mochajs.org/#configuring-mocha-nodejs). We recommend you create a configuration file at your projects root.
mocha.opts is now considered legacy (https://mochajs.org/#mochaopts).

Hopefully this be useful for you in this situation.

If not perhaps you could give more details on the "steps to reproduce" (the ideal anyway).

@craigtaub craigtaub added type: question support question type: feature enhancement proposal and removed type: question support question labels Dec 13, 2018
@paulmelnikow
Copy link
Author

That is fabulous!

Looks like that hasn't shipped yet! Where's the best place to track the release?

@craigtaub
Copy link
Contributor

craigtaub commented Dec 13, 2018

Great.

I think its very close to being released. We usually send messages out to usual channels (Twitter/Gitter etc) but you could track via a Github "Releases only" notification.
Hope that helps.

Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature enhancement proposal
Projects
None yet
Development

No branches or pull requests

2 participants