1
1
import fs from 'node:fs/promises' ;
2
2
import { scheduler } from 'node:timers/promises' ;
3
3
import { mm , MockApplication } from '@eggjs/mock' ;
4
- import { escape , getFilepath , DELAY } from './utils.js' ;
4
+ import { escape , getFilepath } from './utils.js' ;
5
5
6
6
describe ( 'test/override.test.ts' , ( ) => {
7
7
let app : MockApplication ;
@@ -23,19 +23,19 @@ describe('test/override.test.ts', () => {
23
23
it ( 'should reload' , async ( ) => {
24
24
const filepath = getFilepath ( 'override/app/service/a.js' ) ;
25
25
await fs . writeFile ( filepath , '' ) ;
26
- await scheduler . wait ( DELAY ) ;
27
-
26
+ await scheduler . wait ( 1000 ) ;
28
27
await fs . unlink ( filepath ) ;
28
+ await scheduler . wait ( 5000 ) ;
29
29
app . expect ( 'stdout' , / a \. j s / ) ;
30
30
} ) ;
31
31
32
32
it ( 'should not reload' , async ( ) => {
33
33
app . debug ( ) ;
34
34
const filepath = getFilepath ( 'override/app/no-trigger/index.js' ) ;
35
35
await fs . writeFile ( filepath , '' ) ;
36
- await scheduler . wait ( DELAY ) ;
37
-
36
+ await scheduler . wait ( 1000 ) ;
38
37
await fs . unlink ( filepath ) ;
38
+ await scheduler . wait ( 5000 ) ;
39
39
app . notExpect ( 'stdout' , / i n d e x \. j s / ) ;
40
40
} ) ;
41
41
} ) ;
@@ -52,19 +52,19 @@ describe('test/override.test.ts', () => {
52
52
it ( 'should reload' , async ( ) => {
53
53
const filepath = getFilepath ( 'override-ignore/app/web/a.js' ) ;
54
54
await fs . writeFile ( filepath , '' ) ;
55
- await scheduler . wait ( DELAY ) ;
56
-
55
+ await scheduler . wait ( 1000 ) ;
57
56
await fs . unlink ( filepath ) ;
57
+ await scheduler . wait ( 5000 ) ;
58
58
app . expect ( 'stdout' , new RegExp ( escape ( `reload worker because ${ filepath } ` ) ) ) ;
59
59
} ) ;
60
60
61
61
it ( 'should not reload' , async ( ) => {
62
62
app . debug ( ) ;
63
63
const filepath = getFilepath ( 'override-ignore/app/public/index.js' ) ;
64
64
await fs . writeFile ( filepath , '' ) ;
65
- await scheduler . wait ( DELAY ) ;
66
-
65
+ await scheduler . wait ( 1000 ) ;
67
66
await fs . unlink ( filepath ) ;
67
+ await scheduler . wait ( 5000 ) ;
68
68
app . notExpect ( 'stdout' , new RegExp ( escape ( `reload worker because ${ filepath } change` ) ) ) ;
69
69
} ) ;
70
70
} ) ;
0 commit comments