1
1
import { expect , test } from 'vitest'
2
- import { editFile , getColor , page , untilUpdated } from '~utils'
2
+ import { editFile , getColor , isServe , page , untilUpdated } from '~utils'
3
3
4
4
test ( 'should render' , async ( ) => {
5
5
expect ( await page . textContent ( 'h1' ) ) . toMatch (
@@ -13,7 +13,7 @@ test('should update', async () => {
13
13
expect ( await page . textContent ( 'button' ) ) . toMatch ( 'count is: 1' )
14
14
} )
15
15
16
- test ( 'should hmr' , async ( ) => {
16
+ test . runIf ( isServe ) ( 'should hmr' , async ( ) => {
17
17
editFile ( 'App.jsx' , ( code ) =>
18
18
code . replace ( 'Vite + React + @emotion/react' , 'Updated' ) ,
19
19
)
@@ -42,12 +42,14 @@ test('should update button style', async () => {
42
42
43
43
expect ( await getButtonBorderStyle ( ) ) . toMatch ( '2px solid rgb(0, 0, 0)' )
44
44
45
- editFile ( 'Counter.jsx' , ( code ) =>
46
- code . replace ( 'border: 2px solid #000' , 'border: 4px solid red' ) ,
47
- )
45
+ if ( isServe ) {
46
+ editFile ( 'Counter.jsx' , ( code ) =>
47
+ code . replace ( 'border: 2px solid #000' , 'border: 4px solid red' ) ,
48
+ )
48
49
49
- await untilUpdated ( getButtonBorderStyle , '4px solid rgb(255, 0, 0)' )
50
+ await untilUpdated ( getButtonBorderStyle , '4px solid rgb(255, 0, 0)' )
50
51
51
- // preserve state
52
- expect ( await page . textContent ( 'button' ) ) . toMatch ( 'count is: 1' )
52
+ // preserve state
53
+ expect ( await page . textContent ( 'button' ) ) . toMatch ( 'count is: 1' )
54
+ }
53
55
} )
0 commit comments