@@ -189,7 +189,7 @@ describe('bin/node-lambda', () => {
189
189
} )
190
190
} )
191
191
192
- describe ( 'node-lambda run (Multiple events)) ' , ( ) => {
192
+ describe ( 'node-lambda run (Multiple events)' , ( ) => {
193
193
const eventObj = [ {
194
194
asyncTest : false ,
195
195
callbackWaitsForEmptyEventLoop : true ,
@@ -217,7 +217,7 @@ describe('bin/node-lambda', () => {
217
217
} )
218
218
} )
219
219
220
- describe ( 'node-lambda run (disable Multiple events)) ' , ( ) => {
220
+ describe ( 'node-lambda run (disable Multiple events)' , ( ) => {
221
221
const eventObj = [ {
222
222
asyncTest : false ,
223
223
callbackWaitsForEmptyEventLoop : true ,
@@ -264,7 +264,7 @@ describe('bin/node-lambda', () => {
264
264
} )
265
265
} )
266
266
267
- describe ( 'node-lambda run (API Gateway events)) ' , ( ) => {
267
+ describe ( 'node-lambda run (API Gateway events)' , ( ) => {
268
268
const eventObj = {
269
269
asyncTest : false ,
270
270
callbackWaitsForEmptyEventLoop : true ,
@@ -295,6 +295,54 @@ describe('bin/node-lambda', () => {
295
295
} )
296
296
} )
297
297
} )
298
+
299
+ describe ( 'node-lambda run (by *.mjs)' , ( ) => {
300
+ it ( '`node-lambda run` by index.mjs' , function ( done ) {
301
+ const run = spawn ( 'node' , [
302
+ nodeLambdaPath , 'run' ,
303
+ '--handler' , 'index_mjs.handler'
304
+ ] )
305
+ let stdoutString = ''
306
+ run . stdout . on ( 'data' , ( data ) => {
307
+ stdoutString += data . toString ( ) . replace ( / \r | \n | \s / g, '' )
308
+ } )
309
+
310
+ run . on ( 'exit' , ( code ) => {
311
+ const expected = 'Runningindex.handler(mjs)' +
312
+ '==================================' +
313
+ 'event{asyncTest:false,callbackWaitsForEmptyEventLoop:true,callbackCode:\'callback(null);\'}' +
314
+ '==================================' +
315
+ 'Stoppingindex.handler(mjs)Success:'
316
+ assert . equal ( stdoutString , expected )
317
+ assert . equal ( code , 0 )
318
+ done ( )
319
+ } )
320
+ } )
321
+ } )
322
+
323
+ describe ( 'node-lambda run (handler file not found)' , ( ) => {
324
+ it ( '`node-lambda run` Invalid handler specification.' , function ( done ) {
325
+ const run = spawn ( 'node' , [
326
+ nodeLambdaPath , 'run' ,
327
+ '--handler' , 'not_found.handler'
328
+ ] )
329
+ let stdoutString = ''
330
+ run . stdout . on ( 'data' , ( data ) => {
331
+ stdoutString += data . toString ( ) . replace ( / \r | \n | \s / g, '' )
332
+ } )
333
+ let stderrString = ''
334
+ run . stderr . on ( 'data' , ( data ) => {
335
+ stderrString += data . toString ( )
336
+ } )
337
+
338
+ run . on ( 'exit' , ( code ) => {
339
+ assert . equal ( stdoutString , '' )
340
+ assert . match ( stderrString , / H a n d l e r f i l e n o t f o u n d \. / )
341
+ assert . equal ( code , 255 )
342
+ done ( )
343
+ } )
344
+ } )
345
+ } )
298
346
} )
299
347
300
348
describe ( 'node-lambda duplicate check of short option' , ( ) => {
0 commit comments