@@ -42,13 +42,23 @@ describe('middleware', () => {
42
42
}
43
43
44
44
function close ( done ) {
45
- instance . close ( ) ;
45
+ if ( instance . context . watching . closed ) {
46
+ if ( listen ) {
47
+ listen . close ( done ) ;
48
+ } else {
49
+ done ( ) ;
50
+ }
46
51
47
- if ( listen ) {
48
- listen . close ( done ) ;
49
- } else {
50
- done ( ) ;
52
+ return ;
51
53
}
54
+
55
+ instance . close ( ( ) => {
56
+ if ( listen ) {
57
+ listen . close ( done ) ;
58
+ } else {
59
+ done ( ) ;
60
+ }
61
+ } ) ;
52
62
}
53
63
54
64
describe ( 'basic' , ( ) => {
@@ -2147,10 +2157,10 @@ describe('middleware', () => {
2147
2157
listen = listenShorthand ( done ) ;
2148
2158
} ) ;
2149
2159
2150
- afterAll ( ( ) => {
2160
+ afterAll ( ( done ) => {
2151
2161
spy . mockRestore ( ) ;
2152
2162
2153
- close ( ) ;
2163
+ close ( done ) ;
2154
2164
} ) ;
2155
2165
2156
2166
it ( 'should pass arguments to the "watch" method' , ( done ) => {
@@ -2186,10 +2196,10 @@ describe('middleware', () => {
2186
2196
listen = listenShorthand ( done ) ;
2187
2197
} ) ;
2188
2198
2189
- afterAll ( ( ) => {
2199
+ afterAll ( ( done ) => {
2190
2200
spy . mockRestore ( ) ;
2191
2201
2192
- close ( ) ;
2202
+ close ( done ) ;
2193
2203
} ) ;
2194
2204
2195
2205
it ( 'should pass arguments to the "watch" method' , ( done ) => {
@@ -2228,10 +2238,10 @@ describe('middleware', () => {
2228
2238
listen = listenShorthand ( done ) ;
2229
2239
} ) ;
2230
2240
2231
- afterAll ( ( ) => {
2241
+ afterAll ( ( done ) => {
2232
2242
spy . mockRestore ( ) ;
2233
2243
2234
- close ( ) ;
2244
+ close ( done ) ;
2235
2245
} ) ;
2236
2246
2237
2247
it ( 'should pass arguments to the "watch" method' , ( done ) => {
@@ -2283,10 +2293,10 @@ describe('middleware', () => {
2283
2293
listen = listenShorthand ( done ) ;
2284
2294
} ) ;
2285
2295
2286
- afterAll ( ( ) => {
2296
+ afterAll ( ( done ) => {
2287
2297
del . sync ( path . posix . resolve ( __dirname , './outputs/write-to-disk-true' ) ) ;
2288
2298
2289
- close ( ) ;
2299
+ close ( done ) ;
2290
2300
} ) ;
2291
2301
2292
2302
it ( 'should find the bundle file on disk' , ( done ) => {
@@ -2412,12 +2422,12 @@ describe('middleware', () => {
2412
2422
listen = listenShorthand ( done ) ;
2413
2423
} ) ;
2414
2424
2415
- afterAll ( ( ) => {
2425
+ afterAll ( ( done ) => {
2416
2426
del . sync (
2417
2427
path . posix . resolve ( __dirname , './outputs/write-to-disk-function-true' )
2418
2428
) ;
2419
2429
2420
- close ( ) ;
2430
+ close ( done ) ;
2421
2431
} ) ;
2422
2432
2423
2433
it ( 'should find the bundle file on disk' , ( done ) => {
@@ -2465,15 +2475,15 @@ describe('middleware', () => {
2465
2475
listen = listenShorthand ( done ) ;
2466
2476
} ) ;
2467
2477
2468
- afterAll ( ( ) => {
2478
+ afterAll ( ( done ) => {
2469
2479
del . sync (
2470
2480
path . posix . resolve (
2471
2481
__dirname ,
2472
2482
'./outputs/write-to-disk-function-false'
2473
2483
)
2474
2484
) ;
2475
2485
2476
- close ( ) ;
2486
+ close ( done ) ;
2477
2487
} ) ;
2478
2488
2479
2489
it ( 'should not find the bundle file on disk' , ( done ) => {
@@ -2519,12 +2529,12 @@ describe('middleware', () => {
2519
2529
listen = listenShorthand ( done ) ;
2520
2530
} ) ;
2521
2531
2522
- afterAll ( ( ) => {
2532
+ afterAll ( ( done ) => {
2523
2533
del . sync (
2524
2534
path . posix . resolve ( __dirname , './outputs/write-to-disk-query-string' )
2525
2535
) ;
2526
2536
2527
- close ( ) ;
2537
+ close ( done ) ;
2528
2538
} ) ;
2529
2539
2530
2540
it ( 'should find the bundle file on disk with no querystring' , ( done ) => {
@@ -2584,15 +2594,15 @@ describe('middleware', () => {
2584
2594
listen = listenShorthand ( done ) ;
2585
2595
} ) ;
2586
2596
2587
- afterAll ( ( ) => {
2597
+ afterAll ( ( done ) => {
2588
2598
del . sync (
2589
2599
path . posix . resolve (
2590
2600
__dirname ,
2591
2601
'./outputs/write-to-disk-multi-compiler/'
2592
2602
)
2593
2603
) ;
2594
2604
2595
- close ( ) ;
2605
+ close ( done ) ;
2596
2606
} ) ;
2597
2607
2598
2608
it ( 'should find the bundle files on disk' , ( done ) => {
@@ -2667,12 +2677,12 @@ describe('middleware', () => {
2667
2677
} ) ;
2668
2678
} ) ;
2669
2679
2670
- afterAll ( ( ) => {
2680
+ afterAll ( ( done ) => {
2671
2681
del . sync (
2672
2682
path . posix . resolve ( __dirname , './outputs/write-to-disk-with-hash/' )
2673
2683
) ;
2674
2684
2675
- close ( ) ;
2685
+ close ( done ) ;
2676
2686
} ) ;
2677
2687
2678
2688
it ( 'should find the bundle file on disk' , ( done ) => {
@@ -3269,10 +3279,10 @@ describe('middleware', () => {
3269
3279
listen = listenShorthand ( done ) ;
3270
3280
} ) ;
3271
3281
3272
- afterAll ( ( ) => {
3282
+ afterAll ( ( done ) => {
3273
3283
isDirectory . mockRestore ( ) ;
3274
3284
3275
- close ( ) ;
3285
+ close ( done ) ;
3276
3286
} ) ;
3277
3287
3278
3288
it ( 'should return the "404" code for the "GET" request to the public path' , ( done ) => {
@@ -3581,22 +3591,22 @@ describe('middleware', () => {
3581
3591
listen = listenShorthand ( done ) ;
3582
3592
} ) ;
3583
3593
3584
- afterAll ( ( ) => {
3594
+ afterAll ( ( done ) => {
3585
3595
del . sync (
3586
3596
path . posix . resolve ( __dirname , './outputs/write-to-disk-mkdir-error' )
3587
3597
) ;
3588
3598
3589
3599
mkdirSpy . mockRestore ( ) ;
3600
+
3601
+ close ( done ) ;
3590
3602
} ) ;
3591
3603
3592
3604
it ( 'should logging' , ( done ) => {
3593
3605
compiler . hooks . failed . tap ( 'FailedCatcher' , ( ) => {
3594
3606
instance . close ( ( ) => {
3595
3607
expect ( getLogsPlugin . logs ) . toMatchSnapshot ( ) ;
3596
3608
3597
- listen . close ( ( ) => {
3598
- done ( ) ;
3599
- } ) ;
3609
+ done ( ) ;
3600
3610
} ) ;
3601
3611
} ) ;
3602
3612
} ) ;
@@ -3638,7 +3648,7 @@ describe('middleware', () => {
3638
3648
listen = listenShorthand ( done ) ;
3639
3649
} ) ;
3640
3650
3641
- afterAll ( ( ) => {
3651
+ afterAll ( ( done ) => {
3642
3652
writeFileSpy . mockRestore ( ) ;
3643
3653
3644
3654
del . sync (
@@ -3648,17 +3658,15 @@ describe('middleware', () => {
3648
3658
)
3649
3659
) ;
3650
3660
3651
- close ( ) ;
3661
+ close ( done ) ;
3652
3662
} ) ;
3653
3663
3654
3664
it ( 'should logging' , ( done ) => {
3655
3665
compiler . hooks . failed . tap ( 'FailedCatcher' , ( ) => {
3656
3666
instance . close ( ( ) => {
3657
3667
expect ( getLogsPlugin . logs ) . toMatchSnapshot ( ) ;
3658
3668
3659
- listen . close ( ( ) => {
3660
- done ( ) ;
3661
- } ) ;
3669
+ done ( ) ;
3662
3670
} ) ;
3663
3671
} ) ;
3664
3672
} ) ;
0 commit comments