File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 44
44
" David Bunker (https://github.com/dbunker)" ,
45
45
" demetriusnunes (https://github.com/demetriusnunes)" ,
46
46
" DJCrabhat (https://github.com/djcrabhat)" ,
47
+ " Domas Lasauskas (https://github.com/domaslasauskas)" ,
47
48
" Echo Nolan (https://github.com/enolan)" ,
48
49
" Egor Kislitsyn (https://github.com/minibikini)" ,
49
50
" Elliott Spira (https://github.com/em0ney)" ,
Original file line number Diff line number Diff line change @@ -779,7 +779,7 @@ class Offline {
779
779
const x = handler ( event , lambdaContext , lambdaContext . done ) ;
780
780
781
781
// Promise support
782
- if ( serviceRuntime === 'babel' && ! this . requests [ requestId ] . done ) {
782
+ if ( ( serviceRuntime === 'nodejs8.10' || serviceRuntime === ' babel') && ! this . requests [ requestId ] . done ) {
783
783
if ( x && typeof x . then === 'function' && typeof x . catch === 'function' ) x . then ( lambdaContext . succeed ) . catch ( lambdaContext . fail ) ;
784
784
else if ( x instanceof Error ) lambdaContext . fail ( x ) ;
785
785
}
Original file line number Diff line number Diff line change @@ -387,7 +387,6 @@ describe('Offline', () => {
387
387
else {
388
388
cb ( 'JSON body was mangled' ) ;
389
389
}
390
-
391
390
} ) . toObject ( ) ;
392
391
done ( ) ;
393
392
} ) ;
@@ -421,4 +420,35 @@ describe('Offline', () => {
421
420
} ) ;
422
421
} ) ;
423
422
} ) ;
423
+
424
+ context ( 'aws runtime nodejs8.10' , ( ) => {
425
+ const serverless = { service : { provider : {
426
+ name : 'aws' ,
427
+ stage : 'dev' ,
428
+ region : 'us-east-1' ,
429
+ runtime : 'nodejs8.10' ,
430
+ } } } ;
431
+
432
+ it ( 'should support handler returning Promise' , done => {
433
+ const offLine = new OffLineBuilder ( new ServerlessBuilder ( serverless ) )
434
+ . addFunctionHTTP ( 'index' , {
435
+ path : 'index' ,
436
+ method : 'GET' ,
437
+ } , ( event , context ) => Promise . resolve ( {
438
+ statusCode : 200 ,
439
+ body : JSON . stringify ( { message : 'Hello World' } ) ,
440
+ } ) ) . toObject ( ) ;
441
+
442
+ offLine . inject ( {
443
+ method : 'GET' ,
444
+ url : '/index' ,
445
+ payload : { data : 'input' } ,
446
+ } , res => {
447
+ expect ( res . headers ) . to . have . property ( 'content-type' , 'application/json' ) ;
448
+ expect ( res . statusCode ) . to . eq ( 200 ) ;
449
+ expect ( res . payload ) . to . eq ( '{"message":"Hello World"}' ) ;
450
+ done ( ) ;
451
+ } ) ;
452
+ } ) ;
453
+ } ) ;
424
454
} ) ;
You can’t perform that action at this time.
0 commit comments