-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Migrating from mocha.opts to mocharc broke glob pattern support #4307
Comments
I confirm, I have the same problem. |
@TheOptimisticFactory thank you for your detailed description. It's the |
@juergba From the looks of it, one possible fix would be to do an additional globbing pass over the raw |
@rgroothuijsen I don't know. I don't really like the idea to have two glob expansion steps in two different places. There could be more comma-delimited glob patterns than just brace expansion?
|
@juergba Just as a note, commas are sometimes necessary in forms like this: |
IMO the best way to solve this, is to remove the comma splitting for options which could contain glob patterns: @TheOptimisticFactory @adjerbetian if you have some time left ... const globOptions = ['spec', 'ignore']; // new
const coerceOpts = Object.assign(
types.array.reduce(
(acc, arg) =>
Object.assign(acc, {
[arg]: v => Array.from(new Set(globOptions.includes(arg) ? v : list(v))) // modified
}),
{}
),
.... |
@juergba I just tested, it works with me 👍 |
@juergba I also confirm your diff fixes the issue in all my projects 👍 |
@adjerbetian @TheOptimisticFactory thank you! |
Prerequisites
Click for details
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
Using
opts configuration
, the glob pattern{controllers,test}/**/*.test.js
used to expand into:controllers/**/*.test.js
test/**/*.test.js
Using RC configration files, this glob partten gets tokenized into invalid ones:
coerce: coerceOpts
fixes the glob tokenization, even though it isn't a long-term fix.coerceOtps
function can be found here: https://github.com/mochajs/mocha/blob/master/lib/cli/options.js#L63As a side I should add that these two following
spec
values give the results highlighted abovespec: '{controllers,test}/**/*.test.js',
spec: [ '{controllers,test}/**/*.test.js' ],
Steps to Reproduce
I created a barebone repository to highlight the issue: https://github.com/TheOptimisticFactory/mocha-glob-issue
git clone [email protected]:TheOptimisticFactory/mocha-glob-issue.git
cd mocha-glob-issue && npm i
npm run test-legacy-working
: Check tests passes when using lecacy optstest/mocha.opts
npm run test-bugged-baseline
: tests WONT BE FOUND when using.mocharc.js
npm run test-bugged-showcase
: Dumps the BROKEN file patterns when using.mocha.multi-paths.js
LEGACY behavior: [What used to happen]
LEGACY configuration file: /test/mocha.opts
npm run test-legacy-working
Actual behavior: [What actually happens]
Using .mocharc.js
npm run test-bugged-baseline
Using .mocharc.multi-paths.js
npm run test-bugged-showcase
Reproduces how often: [What percentage of the time does it reproduce?]
About 100% of the time :)
Versions
The text was updated successfully, but these errors were encountered: