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 require option for multiple entries #173

Merged
merged 3 commits into from
Apr 27, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});