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

Fix backwards compatibility break for reporterOptions #4153

Merged
merged 1 commit into from Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
24 changes: 24 additions & 0 deletions test/unit/mocha.spec.js
Expand Up @@ -446,6 +446,30 @@ 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');
// To support the legacy property name that can be used by reporters
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');
// To support the legacy property name that can be used by reporters
expect(mocha.options.reporterOptions, 'to have property', 'foo', 'bar');
});
holm marked this conversation as resolved.
Show resolved Hide resolved
});

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