Skip to content

Commit

Permalink
closes #4142
Browse files Browse the repository at this point in the history
In #4004 there was a change to use the documented `reporterOption` in favour of the setting that had always been used in practice called `reporterOptions`. This broke a lot of configurations that used the `reporterOptions`, which was the only way it every worked AFAIK.

This changes the documentation to specify `reporterOptions` instead and ensure that any one that has switched to `reporterOption` after upgrade, still works.
  • Loading branch information
Christian Holm committed Jan 19, 2020
1 parent 0e1ccbb commit dd5ef42
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/mocha.js
Expand Up @@ -100,7 +100,10 @@ function Mocha(options) {
this.grep(options.grep)
.fgrep(options.fgrep)
.ui(options.ui)
.reporter(options.reporter, options.reporterOption)
.reporter(
options.reporter,
options.reporterOption || options.reporterOptions // reporterOptions was previously the only way to specify options to reporter
)
.slow(options.slow)
.global(options.global);

Expand Down
30 changes: 30 additions & 0 deletions test/unit/mocha.spec.js
Expand Up @@ -446,6 +446,36 @@ describe('Mocha', function() {
var mocha = new Mocha(opts);
expect(mocha.reporter(), 'to be', mocha);
});

it('should keep reporterOption on options', function() {
var mocha = new Mocha({
reporter: 'spec',
reporterOption: {
foo: 'bar'
}
});
expect(mocha.options.reporterOption, 'to have property', 'foo', 'bar');
});

it('should alias reporterOption to legacy reporterOptions', function() {
var mocha = new Mocha({
reporter: 'spec',
reporterOption: {
foo: 'bar'
}
});
expect(mocha.options.reporterOptions, 'to have property', 'foo', 'bar');
});

it('should support legacy reporterOptions', function() {
var mocha = new Mocha({
reporter: 'spec',
reporterOptions: {
foo: 'bar'
}
});
expect(mocha.options.reporterOption, 'to have property', 'foo', 'bar');
});
});

describe('#run(fn)', function() {
Expand Down

0 comments on commit dd5ef42

Please sign in to comment.