-
Notifications
You must be signed in to change notification settings - Fork 250
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
feat(mocha 6): support all config formats #1511
Conversation
Add support for all mocha's configuration formats: * Arguments specified on command-line * Configuration file (.mocharc.js, .mocharc.yml, etc.) 1. .mocharc.js 2. .mocharc.yaml 3. .mocharc.yml 4. .mocharc.jsonc 5. .mocharc.json * mocha property of package.json * mocha.opts This works by using mocha 6's [`loadOptions`](https://mochajs.org/api/module-lib_cli_options.html#.loadOptions) function if it is available. If not (mocha < 6), use old parsing logic. See https://mochajs.org/#configuring-mocha-nodejs
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.
Looks good! I got a small comment on the code itself.
Also, did you want to add the deprecation warning in a different PR or this one?
const mochaOptions = Object.assign({}, config[mochaOptionsKey]) as MochaRunnerOptions; | ||
return Object.assign(this.loadMochaOptsFile(mochaOptions.opts), mochaOptions); | ||
public load(strykerOptions: StrykerOptions): MochaOptions { | ||
const mochaOptions = Object.assign({}, strykerOptions[mochaOptionsKey]) as MochaOptions; |
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.
Let's use a spread operator for this { ...strykerOptions[mochaOptionsKey] }
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.
Done
return Object.assign(this.loadMochaOptsFile(mochaOptions.opts), mochaOptions); | ||
public load(strykerOptions: StrykerOptions): MochaOptions { | ||
const mochaOptions = Object.assign({}, strykerOptions[mochaOptionsKey]) as MochaOptions; | ||
return Object.assign(this.loadMochaOptions(mochaOptions), mochaOptions); |
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.
Let's use a spread operator for this { ...this.loadMochaOptions(mochaOptions), ...mochaOptions }
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.
Done
Different PR sounds good. That way, we can already release this without a breaking change. |
Add support for all mocha's configuration formats:
This works by using mocha 6's
loadOptions
function if it is available.If not (mocha < 6), use old parsing logic.
See https://mochajs.org/#configuring-mocha-nodejs
Closes #1414