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

feat(mocha 6): support all config formats #1511

Merged
merged 3 commits into from
Apr 19, 2019
Merged

Conversation

nicojs
Copy link
Member

@nicojs nicojs commented Apr 18, 2019

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 function if it is available.
If not (mocha < 6), use old parsing logic.

See https://mochajs.org/#configuring-mocha-nodejs

Closes #1414

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
@ghost ghost assigned nicojs Apr 18, 2019
@ghost ghost added the 🔎 Needs review label Apr 18, 2019
@nicojs nicojs requested a review from simondel April 18, 2019 14:12
Copy link
Member

@simondel simondel left a 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;
Copy link
Member

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] }

Copy link
Member Author

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);
Copy link
Member

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 }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@nicojs
Copy link
Member Author

nicojs commented Apr 19, 2019

Also, did you want to add the deprecation warning in a different PR or this one?

Different PR sounds good. That way, we can already release this without a breaking change.

@nicojs nicojs merged commit baa374d into master Apr 19, 2019
@ghost ghost removed the 🔎 Needs review label Apr 19, 2019
@nicojs nicojs deleted the 1414-add-mocha-6-support branch April 19, 2019 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for mocha 6
2 participants