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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃殌 Feature: Support granular configuration #3781

Closed
boneskull opened this issue Feb 27, 2019 · 7 comments
Closed

馃殌 Feature: Support granular configuration #3781

boneskull opened this issue Feb 27, 2019 · 7 comments
Labels
status: wontfix typically a feature which won't be added, or a "bug" which is actually intended behavior type: feature enhancement proposal

Comments

@boneskull
Copy link
Member

Mocha v6 now has configuration file support.

Originally, I had hoped this system could work more like ESLint's, where e.g., .mocharc.json files could exist in multiple directories and affect only the test files at, and "below", this directory level.

Given that we can't get this behavior for free (there's overhead and complexity involved), do people think it's useful? Do people use this in ESLint?

A counter-example is Mocha's own .eslintrc.yml, which uses the overrides property to change ESLint's behavior on a per-file or per-directory basis. This is another way of expressing the same thing as multiple ESLint config files, except using only a single config.

At minimum, greater control over which test files use which config settings would be a positive. Mocha's own tests could leverage such a feature. Maybe all we need to do is support something like overrides for now...?

@boneskull boneskull added type: feature enhancement proposal status: accepting prs Mocha can use your help with this one! type: discussion debates, philosophy, navel-gazing, etc. labels Feb 27, 2019
@boneskull boneskull changed the title per-directory configuration files? support granular configuration Feb 27, 2019
@plroebuck
Copy link
Contributor

Are we planning to drop the word "simple" from project description?

@bdcarr
Copy link

bdcarr commented Aug 9, 2019

Came here looking for exactly this! Right now my team runs our tests on our locals via IntelliJ. If a test needs the --delay flag I need to tell whoever's running it to set a run configuration with that flag, rather than being able to just go "hey run this test".

Per-directory or even per-file (via filename matching) config files would be fantastic.

@betweenbrain
Copy link

For our team, being able to override the default configuration per directory, or better yet per file, would be fantastic.

@dcaillibaud
Copy link

馃憤 for at least a per directory override, like it was possible with mocha.opts

It could be done allowing .mocharc.js in all directories, or reading an override property in the main configuration like eslint does, eg :

  "mocha": {
    "recursive": true,
    "reporter": "spec",
    "overrides": [{
      "files": "test/**/*.test.js",
      "require": "@babel/register"
    }, {
      "files": "testBrowser/**/*.test.js",
      "require": "./testBrowser/init.js",
      "slow": 5000,
      "timeout": 10000
    }]
  }

@jedwards1211
Copy link

jedwards1211 commented Dec 19, 2020

I kind of wish I had this for working with VSCode extensions for running Mocha tests (running specific tests via --grep is becoming my biggest hassle with Mocha, so extensions would be a lot more convenient for this. Though I guess I should try .only). The two popular ones won't work for me because they only support one global mocha configuration for the entire project, but I'm running different mocha commands for unit tests, selenium tests, database integration tests, etc.

I do kind of wish the extensions would just let me configure my own command to launch mocha, since I'm running it via build tasks that ensure docker containers are running etc. That would be more ideal. But if nothing else, having per-directory mocha configs would make it more likely I could use one of those VSCode extensions.

@srsudar
Copy link

srsudar commented Feb 3, 2022

Did anyone find a way to do this with the project as-is? I have a project that runs with something like:

  • test/backend/**: mocha --require extra-config-file.js
  • test/frontend/**: mocha

Similar to a comment above, this means I can't just tell people to run a test. We have a script as a workaround, but with integrating with something like Intellij, that doesn't seem possible. Would be great if there was a way to do it, or if anyone had any tricks on how they've been doing it.

@JoshuaKGoldberg JoshuaKGoldberg removed status: accepting prs Mocha can use your help with this one! type: discussion debates, philosophy, navel-gazing, etc. labels Dec 27, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title support granular configuration 馃殌 Feature: Support granular configuration Dec 27, 2023
@JoshuaKGoldberg
Copy link
Member

Per #5027, we're trying to avoid big shakeups. This would be a pretty big one.

Amusingly, even ESLint is moving away from nested configurations! https://eslint.org/blog/2022/08/new-config-system-part-2/

Thanks for the discussion all! Closing as wontfix. 馃

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2024
@JoshuaKGoldberg JoshuaKGoldberg added the status: wontfix typically a feature which won't be added, or a "bug" which is actually intended behavior label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wontfix typically a feature which won't be added, or a "bug" which is actually intended behavior type: feature enhancement proposal
Projects
None yet
Development

No branches or pull requests

8 participants