Skip to content

Commit 9c10ada

Browse files
Christian Holmjuergba
Christian Holm
authored andcommitted
Fix backwards compability break for reporterOptions
1 parent a24683f commit 9c10ada

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/mocha.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ function Mocha(options) {
100100
this.grep(options.grep)
101101
.fgrep(options.fgrep)
102102
.ui(options.ui)
103-
.reporter(options.reporter, options.reporterOption)
103+
.reporter(
104+
options.reporter,
105+
options.reporterOption || options.reporterOptions // reporterOptions was previously the only way to specify options to reporter
106+
)
104107
.slow(options.slow)
105108
.global(options.global);
106109

test/unit/mocha.spec.js

+24
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,30 @@ describe('Mocha', function() {
446446
var mocha = new Mocha(opts);
447447
expect(mocha.reporter(), 'to be', mocha);
448448
});
449+
450+
it('should keep reporterOption on options', function() {
451+
var mocha = new Mocha({
452+
reporter: 'spec',
453+
reporterOption: {
454+
foo: 'bar'
455+
}
456+
});
457+
expect(mocha.options.reporterOption, 'to have property', 'foo', 'bar');
458+
// To support the legacy property name that can be used by reporters
459+
expect(mocha.options.reporterOptions, 'to have property', 'foo', 'bar');
460+
});
461+
462+
it('should support legacy reporterOptions', function() {
463+
var mocha = new Mocha({
464+
reporter: 'spec',
465+
reporterOptions: {
466+
foo: 'bar'
467+
}
468+
});
469+
expect(mocha.options.reporterOption, 'to have property', 'foo', 'bar');
470+
// To support the legacy property name that can be used by reporters
471+
expect(mocha.options.reporterOptions, 'to have property', 'foo', 'bar');
472+
});
449473
});
450474

451475
describe('#run(fn)', function() {

0 commit comments

Comments
 (0)