@@ -2,45 +2,46 @@ import fs from 'node:fs';
2
2
import { join } from 'node:path' ;
3
3
import { expect , rspackTest } from '@e2e/helper' ;
4
4
5
- const cwd = __dirname ;
6
-
7
- rspackTest ( 'HMR should work by default' , async ( { page, dev, editFile } ) => {
8
- await fs . promises . cp ( join ( cwd , 'src' ) , join ( cwd , 'test-temp-src' ) , {
9
- recursive : true ,
10
- } ) ;
11
-
12
- await dev ( {
13
- config : {
14
- source : {
15
- entry : {
16
- index : join ( cwd , 'test-temp-src/index.ts' ) ,
5
+ rspackTest (
6
+ 'HMR should work by default' ,
7
+ async ( { cwd, page, dev, editFile } ) => {
8
+ await fs . promises . cp ( join ( cwd , 'src' ) , join ( cwd , 'test-temp-src' ) , {
9
+ recursive : true ,
10
+ } ) ;
11
+
12
+ await dev ( {
13
+ config : {
14
+ source : {
15
+ entry : {
16
+ index : join ( cwd , 'test-temp-src/index.ts' ) ,
17
+ } ,
17
18
} ,
18
19
} ,
19
- } ,
20
- } ) ;
20
+ } ) ;
21
21
22
- const locator = page . locator ( '#test' ) ;
23
- await expect ( locator ) . toHaveText ( 'Hello Rsbuild!' ) ;
24
- await expect ( locator ) . toHaveCSS ( 'color' , 'rgb(255, 0, 0)' ) ;
22
+ const locator = page . locator ( '#test' ) ;
23
+ await expect ( locator ) . toHaveText ( 'Hello Rsbuild!' ) ;
24
+ await expect ( locator ) . toHaveCSS ( 'color' , 'rgb(255, 0, 0)' ) ;
25
25
26
- const locatorKeep = page . locator ( '#test-keep' ) ;
27
- const keepNum = await locatorKeep . innerHTML ( ) ;
26
+ const locatorKeep = page . locator ( '#test-keep' ) ;
27
+ const keepNum = await locatorKeep . innerHTML ( ) ;
28
28
29
- await editFile ( 'test-temp-src/App.tsx' , ( code ) =>
30
- code . replace ( 'Hello Rsbuild' , 'Hello Test' ) ,
31
- ) ;
29
+ await editFile ( 'test-temp-src/App.tsx' , ( code ) =>
30
+ code . replace ( 'Hello Rsbuild' , 'Hello Test' ) ,
31
+ ) ;
32
32
33
- await expect ( locator ) . toHaveText ( 'Hello Test!' ) ;
33
+ await expect ( locator ) . toHaveText ( 'Hello Test!' ) ;
34
34
35
- // #test-keep should remain unchanged when app.tsx HMR
36
- expect ( await locatorKeep . innerHTML ( ) ) . toBe ( keepNum ) ;
35
+ // #test-keep should remain unchanged when app.tsx HMR
36
+ expect ( await locatorKeep . innerHTML ( ) ) . toBe ( keepNum ) ;
37
37
38
- await editFile (
39
- 'test-temp-src/App.css' ,
40
- ( ) => `#test {
38
+ await editFile (
39
+ 'test-temp-src/App.css' ,
40
+ ( ) => `#test {
41
41
color: rgb(0, 0, 255);
42
42
}` ,
43
- ) ;
43
+ ) ;
44
44
45
- await expect ( locator ) . toHaveCSS ( 'color' , 'rgb(0, 0, 255)' ) ;
46
- } ) ;
45
+ await expect ( locator ) . toHaveCSS ( 'color' , 'rgb(0, 0, 255)' ) ;
46
+ } ,
47
+ ) ;
0 commit comments