From 45143c885f0775637666db29aab13874e47d90be Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Wed, 14 Jun 2017 16:19:26 -0500 Subject: [PATCH] Improve test for `mocha -f` fix --- test/integration/options.spec.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/integration/options.spec.js b/test/integration/options.spec.js index 2461a6a825..d9062cfd9f 100644 --- a/test/integration/options.spec.js +++ b/test/integration/options.spec.js @@ -237,15 +237,17 @@ describe('options', function () { }); describe('--help', function () { - it('works despite the presence of mocha.opts', function (done) { - var output = ''; - try { - fs.mkdirSync(path.resolve(__dirname, 'test-env')); - fs.mkdirSync(path.resolve(__dirname, 'test-env/test')); - fs.writeFileSync(path.resolve(__dirname, 'test-env/test/mocha.opts'), 'foo'); - var mochaLoc = path.resolve(__dirname, '../../bin/mocha'); - output = '' + childProcess.execSync(mochaLoc + ' -h', {cwd: path.resolve(__dirname, 'test-env')}); - } catch (e) {} + before(function () { + fs.mkdirSync(path.resolve(__dirname, 'test-env')); + fs.mkdirSync(path.resolve(__dirname, 'test-env/test')); + fs.writeFileSync(path.resolve(__dirname, 'test-env/test/mocha.opts'), 'foo'); + }); + it('works despite the presence of mocha.opts', function () { + var mochaLoc = path.resolve(__dirname, '../../bin/mocha'); + var output = '' + childProcess.execSync(mochaLoc + ' -h', {cwd: path.resolve(__dirname, 'test-env')}); + expect(output).to.contain('Usage:'); + }); + after(function () { try { fs.unlinkSync(path.resolve(__dirname, 'test-env/test/mocha.opts')); } catch (e) {} @@ -255,8 +257,6 @@ describe('options', function () { try { fs.rmdirSync(path.resolve(__dirname, 'test-env')); } catch (e) {} - assert(output.indexOf('Usage:') >= 0); - done(); }); }); });