Skip to content

Commit 29883fd

Browse files
committed
Add tests for mocha -h fix
1 parent 993853e commit 29883fd

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

@@ -180,4 +183,28 @@ describe('options', function () {
180183
});
181184
});
182185
});
186+
187+
describe('--help', function () {
188+
it('works despite the presence of mocha.opts', function (done) {
189+
var output = '';
190+
try {
191+
fs.mkdirSync(path.resolve(__dirname, 'test-env'));
192+
fs.mkdirSync(path.resolve(__dirname, 'test-env/test'));
193+
fs.writeFileSync(path.resolve(__dirname, 'test-env/test/mocha.opts'), 'foo');
194+
var mochaLoc = path.resolve(__dirname, '../../bin/mocha');
195+
output = '' + childProcess.execSync(mochaLoc + ' -h', {cwd: path.resolve(__dirname, 'test-env')});
196+
} catch (e) {}
197+
try {
198+
fs.unlinkSync(path.resolve(__dirname, 'test-env/test/mocha.opts'));
199+
} catch (e) {}
200+
try {
201+
fs.rmdirSync(path.resolve(__dirname, 'test-env/test'));
202+
} catch (e) {}
203+
try {
204+
fs.rmdirSync(path.resolve(__dirname, 'test-env'));
205+
} catch (e) {}
206+
assert(output.indexOf('Usage:') >= 0);
207+
done();
208+
});
209+
});
183210
});

0 commit comments

Comments
 (0)