@@ -293,7 +293,7 @@ export class Overmind<ThisConfig extends IConfiguration>
293293 const onInitialize = this . createAction (
294294 'onInitialize' ,
295295 configuration . onInitialize
296- )
296+ ) as any
297297
298298 this . initialized = Promise . resolve ( onInitialize ( this ) )
299299 } else {
@@ -371,7 +371,7 @@ export class Overmind<ThisConfig extends IConfiguration>
371371 this . actionReferences . push ( action )
372372 const actionFunc = async ( value ?) => {
373373 if ( IS_PRODUCTION || action [ IS_OPERATOR ] ) {
374- await new Promise ( ( resolve , reject ) => {
374+ return new Promise ( ( resolve , reject ) => {
375375 const execution = this . createExecution ( name , action )
376376 this . eventHub . emit ( EventType . ACTION_START , execution )
377377
@@ -451,15 +451,23 @@ export class Overmind<ThisConfig extends IConfiguration>
451451 result : undefined ,
452452 } )
453453 this . eventHub . emit ( EventType . ACTION_END , execution )
454- await result
454+
455+ if ( result ) {
456+ await result
457+ }
458+
455459 return this . options . testMode && execution
456460 }
457461 }
458462
459463 if ( this . options . testMode ) {
460464 const actionCallback = this . options . testMode . actionCallback
461465
462- return ( value ?) => ( actionFunc as any ) ( value ) . then ( actionCallback )
466+ return async ( value ?) => {
467+ const result = await actionFunc ( value )
468+
469+ return actionCallback ( result )
470+ }
463471 }
464472
465473 return actionFunc
0 commit comments