☕️ Classic, reliable, trusted test framework for Node.js and the browser
options 'spec' and 'ignore': no splitting by comma
juergba26c6cae67045
diff --git a/lib/cli/options.js b/lib/cli/options.jsindex 554a294b..c5186591 100644--- a/lib/cli/options.js+++ b/lib/cli/options.js@@ -54,16 +54,19 @@ const configuration = Object.assign({}, YARGS_PARSER_CONFIG, {/*** This is a really fancy way to:- * - ensure unique values for `array`-type options- * - use its array's last element for `boolean`/`number`/`string`- options given multiple times+ * - `array`-type options: ensure unique values and evtl. split comma-delimited lists+ * - `boolean`/`number`/`string`- options: use last element when given multiple times* This is passed as the `coerce` option to `yargs-parser`* @private* @ignore*/+const globOptions = ['spec', 'ignore'];const coerceOpts = Object.assign(types.array.reduce((acc, arg) =>- Object.assign(acc, {[arg]: v => Array.from(new Set(list(v)))}),+ Object.assign(acc, {+ [arg]: v => Array.from(new Set(globOptions.includes(arg) ? v : list(v)))+ }),{}),types.booleandiff --git a/test/node-unit/cli/options.spec.js b/test/node-unit/cli/options.spec.jsindex 085ba5fc..9c112d7d 100644--- a/test/node-unit/cli/options.spec.js+++ b/test/node-unit/cli/options.spec.js@@ -562,7 +562,9 @@ describe('options', function() {readFileSync = sandbox.stub();readFileSync.onFirstCall().throws();findConfig = sandbox.stub().returns('/some/.mocharc.json');- loadConfig = sandbox.stub().returns({spec: '*.spec.js'});+ loadConfig = sandbox+ .stub()+ .returns({spec: '{dirA,dirB}/**/*.spec.js'});findupSync = sandbox.stub();loadOptions = proxyLoadOptions({readFileSync,@@ -573,10 +575,41 @@ describe('options', function() {result = loadOptions(['*.test.js']);});- it('should place both into the positional arguments array', function() {- expect(result, 'to have property', '_', ['*.test.js', '*.spec.js']);+ it('should place both - unsplitted - into the positional arguments array', function() {+ expect(result, 'to have property', '_', [+ '*.test.js',+ '{dirA,dirB}/**/*.spec.js'+ ]);});});});++ describe('"ignore" handling', function() {+ let result;++ beforeEach(function() {+ readFileSync = sandbox.stub();+ readFileSync.onFirstCall().throws();+ findConfig = sandbox.stub().returns('/some/.mocharc.json');+ loadConfig = sandbox+ .stub()+ .returns({ignore: '{dirA,dirB}/**/*.spec.js'});+ findupSync = sandbox.stub();+ loadOptions = proxyLoadOptions({+ readFileSync,+ findConfig,+ loadConfig,+ findupSync+ });+ result = loadOptions(['--ignore', '*.test.js']);+ });++ it('should not split option values by comma', function() {+ expect(result, 'to have property', 'ignore', [+ '*.test.js',+ '{dirA,dirB}/**/*.spec.js'+ ]);+ });+ });});});