Skip to content

Commit 406a0f0

Browse files
committed
Add tests for mocha -h fix
1 parent 0bfd2e6 commit 406a0f0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/integration/options.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
'use strict';
22

33
var assert = require('assert');
4+
var childProcess = require('child_process');
5+
var fs = require('fs');
6+
var path = require('path');
47
var run = require('./helpers').runMochaJSON;
58
var args = [];
69

@@ -232,4 +235,28 @@ describe('options', function () {
232235
});
233236
});
234237
});
238+
239+
describe('--help', function () {
240+
it('works despite the presence of mocha.opts', function (done) {
241+
var output = '';
242+
try {
243+
fs.mkdirSync(path.resolve(__dirname, 'test-env'));
244+
fs.mkdirSync(path.resolve(__dirname, 'test-env/test'));
245+
fs.writeFileSync(path.resolve(__dirname, 'test-env/test/mocha.opts'), 'foo');
246+
var mochaLoc = path.resolve(__dirname, '../../bin/mocha');
247+
output = '' + childProcess.execSync(mochaLoc + ' -h', {cwd: path.resolve(__dirname, 'test-env')});
248+
} catch (e) {}
249+
try {
250+
fs.unlinkSync(path.resolve(__dirname, 'test-env/test/mocha.opts'));
251+
} catch (e) {}
252+
try {
253+
fs.rmdirSync(path.resolve(__dirname, 'test-env/test'));
254+
} catch (e) {}
255+
try {
256+
fs.rmdirSync(path.resolve(__dirname, 'test-env'));
257+
} catch (e) {}
258+
assert(output.indexOf('Usage:') >= 0);
259+
done();
260+
});
261+
});
235262
});

0 commit comments

Comments
 (0)