diff --git a/index.test.js b/index.test.js index 6ccbf6970..45a349966 100644 --- a/index.test.js +++ b/index.test.js @@ -145,7 +145,8 @@ describe('ServerlessWebpack', () => { before(() => { slsw = new ServerlessWebpack(serverless, rawOptions); - if(serverless.processedInput) { // serverless.processedInput does not exist in serverless@<2.0.0 + if (serverless.processedInput) { + // serverless.processedInput does not exist in serverless@<2.0.0 serverless.processedInput.options = processedOptions; } sandbox.stub(slsw, 'cleanup').returns(BbPromise.resolve()); @@ -477,7 +478,7 @@ describe('ServerlessWebpack', () => { test: () => { it('should override the raw options with the processed ones', () => { slsw.hooks.initialize(); - if(serverless.processedInput) { + if (serverless.processedInput) { expect(slsw.options).to.equal(processedOptions); } else { // serverless.processedInput does not exist in serverless@<2.0.0 diff --git a/lib/wpwatch.js b/lib/wpwatch.js index 36c34caff..ecf6940fc 100644 --- a/lib/wpwatch.js +++ b/lib/wpwatch.js @@ -110,9 +110,9 @@ module.exports = { callback(); } else if (canEmit && currentCompileWatch === null) { // eslint-disable-next-line promise/no-promise-in-callback - currentCompileWatch = BbPromise.resolve( - this.serverless.pluginManager.spawn('webpack:compile:watch') - ).then(() => this.serverless.cli.log('Watching for changes...')); + currentCompileWatch = BbPromise.resolve(this.serverless.pluginManager.spawn('webpack:compile:watch')).then( + () => this.serverless.cli.log('Watching for changes...') + ); } }); }; diff --git a/tests/compile.test.js b/tests/compile.test.js index b9134cf98..c929d16c5 100644 --- a/tests/compile.test.js +++ b/tests/compile.test.js @@ -256,7 +256,6 @@ describe('compile', () => { webpackMock.compilerMock.run.reset(); webpackMock.compilerMock.run.yields(null, multiStats); return expect(module.compile()).to.be.fulfilled.then(() => { - console.log(JSON.stringify(module.compileStats.stats[0].externalModules)); expect(module.compileStats.stats[0].externalModules).to.eql([ { external: '@scoped/vendor', origin: undefined }, { external: 'uuid', origin: undefined }, diff --git a/tests/validate.test.js b/tests/validate.test.js index f3eb6ef6e..7eca04b6f 100644 --- a/tests/validate.test.js +++ b/tests/validate.test.js @@ -693,6 +693,48 @@ describe('validate', () => { }); }); + it('should throw error if container image is not well defined', () => { + const testOutPath = 'test'; + const testFunctionsConfig = { + func1: { + artifact: 'artifact-func1.zip', + events: [ + { + http: { + method: 'POST', + path: 'func1path' + } + }, + { + nonhttp: 'non-http' + } + ], + image: { + name: 'custom-image', + command: [] + } + } + }; + + const testConfig = { + entry: 'test', + context: 'testcontext', + output: { + path: testOutPath + }, + getFunction: func => { + return testFunctionsConfig[func]; + } + }; + + _.set(module.serverless.service, 'custom.webpack.config', testConfig); + module.serverless.service.functions = testFunctionsConfig; + globSyncStub.callsFake(filename => [_.replace(filename, '*', 'js')]); + expect(() => { + module.validate(); + }).to.throw(/Either function.handler or function.image must be defined/); + }); + describe('google provider', () => { beforeEach(() => { _.set(module.serverless, 'service.provider.name', 'google');