1
1
import fs from 'node:fs' ;
2
2
import { join } from 'node:path' ;
3
- import { rspackOnlyTest } from '@e2e/helper' ;
3
+ import { expectFile , rspackOnlyTest } from '@e2e/helper' ;
4
4
import { expect } from '@playwright/test' ;
5
5
import { type RsbuildPlugin , createRsbuild } from '@rsbuild/core' ;
6
6
import fse from 'fs-extra' ;
@@ -70,7 +70,9 @@ rspackOnlyTest(
70
70
fse . ensureDirSync ( join ( cwd , 'test-temp-src' ) ) ;
71
71
72
72
const filePath = join ( cwd , 'test-temp-src' , 'index.js' ) ;
73
+ const distPath = join ( cwd , 'dist/index.html' ) ;
73
74
75
+ await fs . promises . rm ( distPath , { recursive : true , force : true } ) ;
74
76
await fs . promises . writeFile ( filePath , "console.log('1');" ) ;
75
77
76
78
const { plugin, names } = createPlugin ( ) ;
@@ -93,10 +95,11 @@ rspackOnlyTest(
93
95
} ) ;
94
96
95
97
const result = await rsbuild . build ( { watch : true } ) ;
98
+ await expectFile ( distPath ) ;
96
99
100
+ await fs . promises . rm ( distPath , { recursive : true , force : true } ) ;
97
101
await fs . promises . writeFile ( filePath , "console.log('2');" ) ;
98
-
99
- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
102
+ await expectFile ( distPath ) ;
100
103
101
104
expect ( names ) . toEqual ( [
102
105
'ModifyRsbuildConfig' ,
0 commit comments