@@ -317,6 +317,7 @@ describe('electron:build', () => {
317
317
318
318
describe ( 'electron:serve' , ( ) => {
319
319
process . env . NODE_ENV = 'development'
320
+ const isWin = process . platform === 'win32'
320
321
321
322
test ( 'typescript is disabled when set in options' , async ( ) => {
322
323
await runCommand ( 'electron:serve' , {
@@ -466,6 +467,7 @@ describe('electron:serve', () => {
466
467
expect ( fs . watchFile . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'projectPath/customBackground' )
467
468
// Child has not yet been killed or unwatched
468
469
expect ( mockExeca . send ) . not . toBeCalled ( )
470
+ expect ( mockExeca . kill ) . not . toBeCalled ( )
469
471
expect ( mockExeca . removeAllListeners ) . not . toBeCalled ( )
470
472
// Main process was bundled and Electron was launched initially
471
473
expect ( webpack ) . toHaveBeenCalledTimes ( 1 )
@@ -475,8 +477,13 @@ describe('electron:serve', () => {
475
477
watchCb ( )
476
478
childEvents . exit ( )
477
479
// Electron was killed and listeners removed
478
- expect ( mockExeca . send ) . toHaveBeenCalledTimes ( 1 )
479
- expect ( mockExeca . send ) . toHaveBeenCalledWith ( 'graceful-exit' )
480
+ if ( isWin ) {
481
+ expect ( mockExeca . send ) . toHaveBeenCalledTimes ( 1 )
482
+ expect ( mockExeca . send ) . toHaveBeenCalledWith ( 'graceful-exit' )
483
+ } else {
484
+ expect ( mockExeca . kill ) . toHaveBeenCalledTimes ( 1 )
485
+ expect ( mockExeca . kill ) . toHaveBeenCalledWith ( 'SIGTERM' )
486
+ }
480
487
// Process did not exit on Electron close
481
488
expect ( process . exit ) . not . toBeCalled ( )
482
489
// Main process file was recompiled
@@ -509,6 +516,7 @@ describe('electron:serve', () => {
509
516
expect ( fs . watchFile . mock . calls [ 1 ] [ 0 ] ) . toBe ( 'projectPath/listFile' )
510
517
// Child has not yet been killed or unwatched
511
518
expect ( mockExeca . send ) . not . toBeCalled ( )
519
+ expect ( mockExeca . kill ) . not . toBeCalled ( )
512
520
expect ( mockExeca . removeAllListeners ) . not . toBeCalled ( )
513
521
// Main process was bundled and Electron was launched initially
514
522
expect ( webpack ) . toHaveBeenCalledTimes ( 1 )
@@ -518,8 +526,13 @@ describe('electron:serve', () => {
518
526
watchCb [ 'projectPath/listFile' ] ( )
519
527
childEvents . exit ( )
520
528
// Electron was killed and listeners removed
521
- expect ( mockExeca . send ) . toHaveBeenCalledTimes ( 1 )
522
- expect ( mockExeca . send ) . toHaveBeenCalledWith ( 'graceful-exit' )
529
+ if ( isWin ) {
530
+ expect ( mockExeca . send ) . toHaveBeenCalledTimes ( 1 )
531
+ expect ( mockExeca . send ) . toHaveBeenCalledWith ( 'graceful-exit' )
532
+ } else {
533
+ expect ( mockExeca . kill ) . toHaveBeenCalledTimes ( 1 )
534
+ expect ( mockExeca . kill ) . toHaveBeenCalledWith ( 'SIGTERM' )
535
+ }
523
536
// Process did not exit on Electron close
524
537
expect ( process . exit ) . not . toBeCalled ( )
525
538
// Main process file was recompiled
@@ -531,8 +544,13 @@ describe('electron:serve', () => {
531
544
watchCb [ 'projectPath/customBackground' ] ( )
532
545
childEvents . exit ( )
533
546
// Electron was killed and listeners removed
534
- expect ( mockExeca . send ) . toHaveBeenCalledTimes ( 2 )
535
- expect ( mockExeca . send ) . toHaveBeenCalledWith ( 'graceful-exit' )
547
+ if ( isWin ) {
548
+ expect ( mockExeca . send ) . toHaveBeenCalledTimes ( 2 )
549
+ expect ( mockExeca . send ) . toHaveBeenCalledWith ( 'graceful-exit' )
550
+ } else {
551
+ expect ( mockExeca . kill ) . toHaveBeenCalledTimes ( 2 )
552
+ expect ( mockExeca . kill ) . toHaveBeenCalledWith ( 'SIGTERM' )
553
+ }
536
554
// Process did not exit on Electron close
537
555
expect ( process . exit ) . not . toBeCalled ( )
538
556
// Main process file was recompiled
0 commit comments