1
1
import { describe , expect , test } from 'vitest'
2
- import { editFile , isServe , page , untilUpdated } from '~utils'
2
+ import { editFile , isServe , page } from '~utils'
3
3
4
4
test ( 'should render' , async ( ) => {
5
5
expect ( await page . textContent ( '.named' ) ) . toMatch ( '0' )
@@ -38,7 +38,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
38
38
editFile ( 'Comps.jsx' , ( code ) =>
39
39
code . replace ( 'named {count' , 'named updated {count' ) ,
40
40
)
41
- await untilUpdated ( ( ) => page . textContent ( '.named' ) , 'named updated 0' )
41
+ await expect
42
+ . poll ( ( ) => page . textContent ( '.named' ) )
43
+ . toMatch ( 'named updated 0' )
42
44
43
45
// affect all components in same file
44
46
expect ( await page . textContent ( '.named-specifier' ) ) . toMatch ( '1' )
@@ -51,10 +53,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
51
53
editFile ( 'Comps.jsx' , ( code ) =>
52
54
code . replace ( 'named specifier {count' , 'named specifier updated {count' ) ,
53
55
)
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' )
58
59
59
60
// affect all components in same file
60
61
expect ( await page . textContent ( '.default' ) ) . toMatch ( '2' )
@@ -66,7 +67,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
66
67
editFile ( 'Comps.jsx' , ( code ) =>
67
68
code . replace ( 'default {count' , 'default updated {count' ) ,
68
69
)
69
- await untilUpdated ( ( ) => page . textContent ( '.default' ) , 'default updated 2' )
70
+ await expect
71
+ . poll ( ( ) => page . textContent ( '.default' ) )
72
+ . toMatch ( 'default updated 2' )
70
73
71
74
// should not affect other components on the page
72
75
expect ( await page . textContent ( '.default-tsx' ) ) . toMatch ( '4' )
@@ -80,10 +83,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
80
83
editFile ( 'Comp.tsx' , ( code ) =>
81
84
code . replace ( 'default tsx {count' , 'default tsx updated {count' ) ,
82
85
)
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' )
87
89
88
90
// should not affect other components on the page
89
91
expect ( await page . textContent ( '.named' ) ) . toMatch ( '1' )
@@ -93,7 +95,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
93
95
editFile ( 'Script.vue' , ( code ) =>
94
96
code . replace ( 'script {count' , 'script updated {count' ) ,
95
97
)
96
- await untilUpdated ( ( ) => page . textContent ( '.script' ) , 'script updated 4' )
98
+ await expect
99
+ . poll ( ( ) => page . textContent ( '.script' ) )
100
+ . toMatch ( 'script updated 4' )
97
101
98
102
expect ( await page . textContent ( '.src-import' ) ) . toMatch ( '6' )
99
103
} )
@@ -103,10 +107,9 @@ describe.runIf(isServe)('vue-jsx server', () => {
103
107
editFile ( 'SrcImport.jsx' , ( code ) =>
104
108
code . replace ( 'src import {count' , 'src import updated {count' ) ,
105
109
)
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' )
110
113
111
114
expect ( await page . textContent ( '.script' ) ) . toMatch ( '5' )
112
115
} )
@@ -115,6 +118,6 @@ describe.runIf(isServe)('vue-jsx server', () => {
115
118
editFile ( 'setup-syntax-jsx.vue' , ( code ) =>
116
119
code . replace ( 'let count = ref(100)' , 'let count = ref(1000)' ) ,
117
120
)
118
- await untilUpdated ( ( ) => page . textContent ( '.setup-jsx' ) , '1000' )
121
+ await expect . poll ( ( ) => page . textContent ( '.setup-jsx' ) ) . toMatch ( '1000' )
119
122
} )
120
123
} )
0 commit comments