diff --git a/browser-entry.js b/browser-entry.js index c496d2715d..4876ad5614 100644 --- a/browser-entry.js +++ b/browser-entry.js @@ -130,12 +130,6 @@ mocha.setup = function(opts) { } for (var opt in opts) { if (opts.hasOwnProperty(opt)) { - if (opt === 'noHighlighting' && opt) { - require('./lib/utils').deprecate( - 'noHighlighting is deprecated; provide {reporterOption: {highlight: false}} to mocha.setup().' - ); - } - if (opt === 'reporterOptions') { this.options.reporterOptions = opts[opt]; } else { diff --git a/lib/mocha.js b/lib/mocha.js index 106c70a2ac..06b626b631 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -682,15 +682,17 @@ Mocha.prototype.asyncOnly = function() { * Disables syntax highlighting (in browser). * * @public + * @param {boolean} enableHighlight - Whether to enable highlight. * @return {Mocha} this * @chainable */ -Mocha.prototype.noHighlighting = function() { +Mocha.prototype.noHighlighting = function(enableHighlight) { utils.deprecate( 'noHighlighting is deprecated; provide {reporterOption: {highlight: false}} to mocha.setup().' ); - - this.options.noHighlighting = true; + this.options.reporterOptions = this.options.reporterOptions || {}; + this.options.reporterOptions.highlight = + enableHighlight !== undefined && enableHighlight !== true; return this; }; diff --git a/lib/reporters/html.js b/lib/reporters/html.js index 6c75d0d660..35d59d7c2a 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -59,19 +59,14 @@ var playIcon = '‣'; */ function HTML(runner, options) { Base.call(this, runner, options); - for (var opt in options) { - if (options.hasOwnProperty(opt) && opt === 'reporterOptions') { - if ( - options[opt] && - (options[opt].highlight || - typeof options[opt].highlight === 'undefined') - ) { - options[opt].highlight = true; - } - if (!options[opt]) { - options[opt] = {highlight: true}; - } - } + + var enableHighlight = true; + if ( + options.reporterOptions && + options.reporterOptions.hasOwnProperty('highlight') && + !options.reporterOptions.highlight + ) { + enableHighlight = false; } var self = this; @@ -240,7 +235,7 @@ function HTML(runner, options) { }); runner.once(EVENT_RUN_END, function() { - if (options.reporterOptions.highlight) { + if (enableHighlight) { utils.highlightTags('code'); } }); diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index 648853feab..4dfe632b29 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -289,10 +289,15 @@ describe('Mocha', function() { describe('#noHighlighting()', function() { // :NOTE: Browser-only option... - it('should set the noHighlighting option to true', function() { + it('should set the reporterOptions.highlight to false', function() { var mocha = new Mocha(opts); mocha.noHighlighting(); - expect(mocha.options, 'to have property', 'noHighlighting', true); + expect( + mocha.options.reporterOptions, + 'to have property', + 'highlight', + false + ); }); it('should be chainable', function() {