From 2356a8f3f425de99cd3e5015847b45c63cdb1433 Mon Sep 17 00:00:00 2001 From: Philipp Muens Date: Wed, 16 Nov 2016 11:38:18 +0100 Subject: [PATCH] Remove unnecessary timeouts in tests --- lib/classes/CLI.test.js | 21 +++++++++-------- lib/classes/PluginManager.test.js | 39 +++++++++++++++++-------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/lib/classes/CLI.test.js b/lib/classes/CLI.test.js index e21325848..fe661efa0 100644 --- a/lib/classes/CLI.test.js +++ b/lib/classes/CLI.test.js @@ -271,11 +271,14 @@ describe('CLI', () => { }); }); - describe('integration tests', () => { - before(function () { + describe('Integration tests', function () { + this.timeout(0); + const that = this; + + before(() => { const tmpDir = testUtils.getTmpDirPath(); - this.cwd = process.cwd(); + that.cwd = process.cwd(); fse.mkdirSync(tmpDir); process.chdir(tmpDir); @@ -286,16 +289,15 @@ describe('CLI', () => { // Cannot rely on shebang in severless.js to invoke script using NodeJS on Windows. const execPrefix = os.platform() === 'win32' ? 'node ' : ''; - this.serverlessExec = execPrefix + path.join(serverless.config.serverlessPath, + that.serverlessExec = execPrefix + path.join(serverless.config.serverlessPath, '..', 'bin', 'serverless'); }); - after(function () { // eslint-disable-line prefer-arrow-callback - process.chdir(this.cwd); + after(() => { + process.chdir(that.cwd); }); - it('prints general --help to stdout', function (done) { - this.timeout(10000); + it('should print general --help to stdout', (done) => { exec(`${this.serverlessExec} --help`, (err, stdout) => { if (err) { done(err); @@ -307,8 +309,7 @@ describe('CLI', () => { }); }); - it('prints command --help to stdout', function (done) { - this.timeout(10000); + it('should print command --help to stdout', (done) => { exec(`${this.serverlessExec} deploy --help`, (err, stdout) => { if (err) { done(err); diff --git a/lib/classes/PluginManager.test.js b/lib/classes/PluginManager.test.js index 02978b4cd..f3c9fed01 100644 --- a/lib/classes/PluginManager.test.js +++ b/lib/classes/PluginManager.test.js @@ -736,27 +736,30 @@ describe('PluginManager', () => { }); }); - it('Plugin/CLI integration', function () { - this.timeout(10000); - const serverlessInstance = new Serverless(); - serverlessInstance.init(); + describe('Plugin / CLI integration', function () { + this.timeout(0); - // Cannot rely on shebang in severless.js to invoke script using NodeJS on Windows. - const execPrefix = os.platform() === 'win32' ? 'node ' : ''; - const serverlessExec = execPrefix + path.join(serverlessInstance.config.serverlessPath, - '..', 'bin', 'serverless'); - const tmpDir = testUtils.getTmpDirPath(); - fse.mkdirSync(tmpDir); - const cwd = process.cwd(); - process.chdir(tmpDir); + it('should expose a working integration between the CLI and the plugin system', () => { + const serverlessInstance = new Serverless(); + serverlessInstance.init(); - execSync(`${serverlessExec} create --template aws-nodejs`); + // Cannot rely on shebang in severless.js to invoke script using NodeJS on Windows. + const execPrefix = os.platform() === 'win32' ? 'node ' : ''; + const serverlessExec = execPrefix + path.join(serverlessInstance.config.serverlessPath, + '..', 'bin', 'serverless'); + const tmpDir = testUtils.getTmpDirPath(); + fse.mkdirSync(tmpDir); + const cwd = process.cwd(); + process.chdir(tmpDir); - expect(serverlessInstance.utils - .fileExistsSync(path.join(tmpDir, 'serverless.yml'))).to.equal(true); - expect(serverlessInstance.utils - .fileExistsSync(path.join(tmpDir, 'handler.js'))).to.equal(true); + execSync(`${serverlessExec} create --template aws-nodejs`); - process.chdir(cwd); + expect(serverlessInstance.utils + .fileExistsSync(path.join(tmpDir, 'serverless.yml'))).to.equal(true); + expect(serverlessInstance.utils + .fileExistsSync(path.join(tmpDir, 'handler.js'))).to.equal(true); + + process.chdir(cwd); + }); }); });