Skip to content

Commit

Permalink
Fix require option for multiple entries (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
marneborn authored and sindresorhus committed Apr 27, 2017
1 parent e878086 commit 55004ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const npmRunPath = require('npm-run-path');

const HUNDRED_MEGABYTES = 1000 * 1000 * 100;

// Mocha options that can be specified multiple times
const MULTIPLE_OPTS = [
'require'
];

module.exports = opts => {
opts = Object.assign({
colors: true,
Expand All @@ -18,7 +23,7 @@ module.exports = opts => {
for (const key of Object.keys(opts)) {
const val = opts[key];

if (Array.isArray(val)) {
if (MULTIPLE_OPTS.indexOf(key) > 0 && Array.isArray(val)) {
opts[key] = val.join(',');
}
}
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/fixture-require1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'use strict';
1 change: 1 addition & 0 deletions test/fixtures/fixture-require2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'use strict';
14 changes: 14 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,18 @@ describe('mocha()', () => {
stream.write(fixture('fixture-pass.js'));
stream.end();
});

it('should require two files', done => {
const stream = mocha({require: [
'test/fixtures/fixture-require1.js',
'test/fixtures/fixture-require2.js'
]});

stream.once('_result', result => {
assert(/1 passing/.test(result.stdout));
done();
});
stream.write(fixture('fixture-pass.js'));
stream.end();
});
});

1 comment on commit 55004ca

@leosco
Copy link

@leosco leosco commented on 55004ca Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that this isn't part of the base https://github.com/mochajs/mocha package. I'm on latest and I still have to do multiple --require options as opposed to providing a comma-separated list

Please sign in to comment.