11import { expect , test } from 'vitest'
2- import { editFile , getColor , page , untilUpdated } from '~utils'
2+ import { editFile , getColor , isServe , page , untilUpdated } from '~utils'
33
44test ( 'should render' , async ( ) => {
55 expect ( await page . textContent ( 'h1' ) ) . toMatch (
@@ -13,7 +13,7 @@ test('should update', async () => {
1313 expect ( await page . textContent ( 'button' ) ) . toMatch ( 'count is: 1' )
1414} )
1515
16- test ( 'should hmr' , async ( ) => {
16+ test . runIf ( isServe ) ( 'should hmr' , async ( ) => {
1717 editFile ( 'App.jsx' , ( code ) =>
1818 code . replace ( 'Vite + React + @emotion/react' , 'Updated' ) ,
1919 )
@@ -42,12 +42,14 @@ test('should update button style', async () => {
4242
4343 expect ( await getButtonBorderStyle ( ) ) . toMatch ( '2px solid rgb(0, 0, 0)' )
4444
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+ )
4849
49- await untilUpdated ( getButtonBorderStyle , '4px solid rgb(255, 0, 0)' )
50+ await untilUpdated ( getButtonBorderStyle , '4px solid rgb(255, 0, 0)' )
5051
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+ }
5355} )
0 commit comments