Skip to content

Commit

Permalink
fix --reporter-option to allow comma-separated options; closes #3706
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
  • Loading branch information
boneskull committed Feb 10, 2019
1 parent 186ca36 commit 4a0d9df
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
@@ -0,0 +1,7 @@
'use strict';

function ReporterWithOptions(runner, options) {
console.log(JSON.stringify(options.reporterOption));
}

module.exports = ReporterWithOptions;
61 changes: 61 additions & 0 deletions test/integration/options/reporter-option.spec.js
@@ -1,6 +1,7 @@
'use strict';

var runMocha = require('../helpers').runMocha;
var path = require('path');

describe('--reporter-option', function() {
describe('when given options w/ invalid format', function() {
Expand All @@ -21,5 +22,65 @@ describe('--reporter-option', function() {
'pipe'
);
});

it('should allow comma-separated values', function(done) {
runMocha(
'passing.fixture.js',
[
'--reporter',
path.join(
__dirname,
'..',
'fixtures',
'options',
'reporter-with-options.fixture.js'
),
'--reporter-option',
'foo=bar,baz=quux'
],
function(err, res) {
if (err) {
return done(err);
}
expect(res, 'to have passed').and(
'to contain output',
/{"foo":"bar","baz":"quux"}/
);
done();
},
'pipe'
);
});

it('should allow repeated options', function(done) {
runMocha(
'passing.fixture.js',
[
'--reporter',
path.join(
__dirname,
'..',
'fixtures',
'options',
'reporter-with-options.fixture.js'
),
'--reporter-option',
'foo=bar',
'--reporter-option',
'baz=quux'
],
function(err, res) {
if (err) {
return done(err);
}
expect(res, 'to have passed').and(
'to contain output',
/{"foo":"bar","baz":"quux"}/
);
done();
},
'pipe'
);
});
});
});

0 comments on commit 4a0d9df

Please sign in to comment.