11import { describe , expect , test } from 'vitest'
2- import { editFile , isServe , page , untilUpdated } from '~utils'
2+ import { editFile , isServe , page } from '~utils'
33
44test ( 'should render' , async ( ) => {
55 expect ( await page . textContent ( '.named' ) ) . toMatch ( '0' )
@@ -38,7 +38,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
3838 editFile ( 'Comps.jsx' , ( code ) =>
3939 code . replace ( 'named {count' , 'named updated {count' ) ,
4040 )
41- await untilUpdated ( ( ) => page . textContent ( '.named' ) , 'named updated 0' )
41+ await expect
42+ . poll ( ( ) => page . textContent ( '.named' ) )
43+ . toMatch ( 'named updated 0' )
4244
4345 // affect all components in same file
4446 expect ( await page . textContent ( '.named-specifier' ) ) . toMatch ( '1' )
@@ -51,10 +53,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
5153 editFile ( 'Comps.jsx' , ( code ) =>
5254 code . replace ( 'named specifier {count' , 'named specifier updated {count' ) ,
5355 )
54- await untilUpdated (
55- ( ) => page . textContent ( '.named-specifier' ) ,
56- 'named specifier updated 1' ,
57- )
56+ await expect
57+ . poll ( ( ) => page . textContent ( '.named-specifier' ) )
58+ . toMatch ( 'named specifier updated 1' )
5859
5960 // affect all components in same file
6061 expect ( await page . textContent ( '.default' ) ) . toMatch ( '2' )
@@ -66,7 +67,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
6667 editFile ( 'Comps.jsx' , ( code ) =>
6768 code . replace ( 'default {count' , 'default updated {count' ) ,
6869 )
69- await untilUpdated ( ( ) => page . textContent ( '.default' ) , 'default updated 2' )
70+ await expect
71+ . poll ( ( ) => page . textContent ( '.default' ) )
72+ . toMatch ( 'default updated 2' )
7073
7174 // should not affect other components on the page
7275 expect ( await page . textContent ( '.default-tsx' ) ) . toMatch ( '4' )
@@ -80,10 +83,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
8083 editFile ( 'Comp.tsx' , ( code ) =>
8184 code . replace ( 'default tsx {count' , 'default tsx updated {count' ) ,
8285 )
83- await untilUpdated (
84- ( ) => page . textContent ( '.default-tsx' ) ,
85- 'default tsx updated 3' ,
86- )
86+ await expect
87+ . poll ( ( ) => page . textContent ( '.default-tsx' ) )
88+ . toMatch ( 'default tsx updated 3' )
8789
8890 // should not affect other components on the page
8991 expect ( await page . textContent ( '.named' ) ) . toMatch ( '1' )
@@ -93,7 +95,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
9395 editFile ( 'Script.vue' , ( code ) =>
9496 code . replace ( 'script {count' , 'script updated {count' ) ,
9597 )
96- await untilUpdated ( ( ) => page . textContent ( '.script' ) , 'script updated 4' )
98+ await expect
99+ . poll ( ( ) => page . textContent ( '.script' ) )
100+ . toMatch ( 'script updated 4' )
97101
98102 expect ( await page . textContent ( '.src-import' ) ) . toMatch ( '6' )
99103 } )
@@ -103,10 +107,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
103107 editFile ( 'SrcImport.jsx' , ( code ) =>
104108 code . replace ( 'src import {count' , 'src import updated {count' ) ,
105109 )
106- await untilUpdated (
107- ( ) => page . textContent ( '.src-import' ) ,
108- 'src import updated 5' ,
109- )
110+ await expect
111+ . poll ( ( ) => page . textContent ( '.src-import' ) )
112+ . toMatch ( 'src import updated 5' )
110113
111114 expect ( await page . textContent ( '.script' ) ) . toMatch ( '5' )
112115 } )
@@ -115,6 +118,6 @@ describe.runIf(isServe)('vue-jsx server', () => {
115118 editFile ( 'setup-syntax-jsx.vue' , ( code ) =>
116119 code . replace ( 'let count = ref(100)' , 'let count = ref(1000)' ) ,
117120 )
118- await untilUpdated ( ( ) => page . textContent ( '.setup-jsx' ) , '1000' )
121+ await expect . poll ( ( ) => page . textContent ( '.setup-jsx' ) ) . toMatch ( '1000' )
119122 } )
120123} )
0 commit comments