-
-
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
fix: extends not working for some settings #4980
base: main
Are you sure you want to change the base?
Conversation
This PR hasn't had any recent activity, and I'm labeling it |
Just pinging to have the |
Note: #4407 also touches this area. We should review them together in case one is a dup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good and reasonable, nice! 🔥
Marking as requesting changes just so we can chat about the two possible implementations a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Praise] As with #4407's tests, these are nice! I like that this also has an added second one for both --config
and file coverage.
|
||
config = yargs(undefined, path.dirname(filepath)) | ||
.parserConfiguration(require('./options').YARGS_PARSER_CONFIG) | ||
.config(config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting https://github.com/mochajs/mocha/pull/4407/files#r1509449877 here: would be nice to have discussion on which API option to use. I'm leaning towards this one, but want to hear if there are advantages to applyExtends
I missed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh darn I wasn't very clear on this. I wanted to ask you @manuth as well as @mochajs/maintenance-crew, does anybody have opinions on using this API vs. yargs/helpers
-> applyExtends
? I'm in favor as-is, but since two PRs tried two different approaches I think I'd want to see if anybody prefers the other approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure anymore why I decided to use this function instead.
I remember that when using a different approach, some options were overridden by default.
I will read through my commit messages during the upcoming weekend. I really hope I can reproduce my thoughts this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 just checking in @manuth, anything I can help with?
Marking as |
Requirements
Description of the Change
As described in issue #4979, due to
mocha
first loading its default settings and after doing so processing the arguments usingargs
, there are some settings which cannot be inherited by specifying anextends
file:mocha/lib/cli/options.js
Line 246 in 37deed2
mocha/lib/cli/cli.js
Line 77 in 37deed2
Changes made in this PR processes configuration files using
yargs
right after they have been parsed. Thus, the order of events is now the following:yargs
package.json
settings are loadedargv
get mergedmocha
s default values (fromlib/mocharc.json
) get appliedAlternate Designs
Configuration files could be processed right before
mocha
s defaults get applied. However, the context of the file path would get lost thus causing relativeextends
paths to possibly fail.Applying
mocha
s default values could be removed from here:https://github.com/mochajs/mocha/blob/37deed262d4bc0788d32c66636495d10038ad398/lib/cli
And instead be done somewhere around here (after
yargs
has been executed):mocha/lib/cli/cli.js
Line 47 in 37deed2
Why should this be in core?
Currently, the inheritance will not work for a number of settings while other settings do. This might cause confusion and unexpected results. Thus, I'd recommend to have this change in core.
Benefits
All settings will be able to be inherited while
mocha
s defaults still get applied if necessary.Possible Drawbacks
None that I have heard of.
If people already used
extends
for their own project, there is a chance that they relied on the inheritance ofui
to not work, so there is a small possibility they will have to perform a one-time change to their config file.Applicable issues
Enter any applicable Issues here.
Mocha follows semantic versioning: http://semver.org
Is this a breaking change (major release)?Is it an enhancement (minor release)? (Maybe?)
Is it a bug fix, or does it not impact production code (patch release)?
Or probably a minor as there is a small possibility people have to adjust their configuration if they used
extends
beforeCo-authored-by: Pat Herlihy @mf-pherlihy