22
33import ReactExports , { StrictMode , Suspense } from 'react'
44import { act , fireEvent , render , screen , waitFor } from '@testing-library/react'
5- import { it } from 'vitest'
5+ import { expect , it } from 'vitest'
66import { proxy , useSnapshot } from 'valtio'
77
88const sleep = ( ms : number ) =>
@@ -39,11 +39,11 @@ it.skipIf(typeof use === 'undefined')('delayed increment', async () => {
3939 </ StrictMode > ,
4040 )
4141
42- await screen . findByText ( 'count: 0' )
42+ expect ( await screen . findByText ( 'count: 0' ) ) . toBeInTheDocument ( )
4343
4444 fireEvent . click ( screen . getByText ( 'button' ) )
45- await screen . findByText ( 'loading' )
46- await screen . findByText ( 'count: 1' )
45+ expect ( await screen . findByText ( 'loading' ) ) . toBeInTheDocument ( )
46+ expect ( await screen . findByText ( 'count: 1' ) ) . toBeInTheDocument ( )
4747} )
4848
4949it . skipIf ( typeof use === 'undefined' ) ( 'delayed object' , async ( ) => {
@@ -70,11 +70,11 @@ it.skipIf(typeof use === 'undefined')('delayed object', async () => {
7070 </ StrictMode > ,
7171 )
7272
73- await screen . findByText ( 'text: none' )
73+ expect ( await screen . findByText ( 'text: none' ) ) . toBeInTheDocument ( )
7474
7575 fireEvent . click ( screen . getByText ( 'button' ) )
76- await screen . findByText ( 'loading' )
77- await screen . findByText ( 'text: hello' )
76+ expect ( await screen . findByText ( 'loading' ) ) . toBeInTheDocument ( )
77+ expect ( await screen . findByText ( 'text: hello' ) ) . toBeInTheDocument ( )
7878} )
7979
8080it . skipIf ( typeof use === 'undefined' ) (
@@ -110,18 +110,18 @@ it.skipIf(typeof use === 'undefined')(
110110 )
111111 } )
112112
113- await screen . findByText ( 'loading' )
113+ expect ( await screen . findByText ( 'loading' ) ) . toBeInTheDocument ( )
114114 await waitFor ( ( ) => {
115- screen . getByText ( 'text: counter' )
116- screen . getByText ( 'count: 0' )
115+ expect ( screen . getByText ( 'text: counter' ) ) . toBeInTheDocument ( )
116+ expect ( screen . getByText ( 'count: 0' ) ) . toBeInTheDocument ( )
117117 } )
118118
119119 fireEvent . click ( screen . getByText ( 'button' ) )
120120
121- await screen . findByText ( 'loading' )
121+ expect ( await screen . findByText ( 'loading' ) ) . toBeInTheDocument ( )
122122 await waitFor ( ( ) => {
123- screen . getByText ( 'text: counter' )
124- screen . getByText ( 'count: 1' )
123+ expect ( screen . getByText ( 'text: counter' ) ) . toBeInTheDocument ( )
124+ expect ( screen . getByText ( 'count: 1' ) ) . toBeInTheDocument ( )
125125 } )
126126 } ,
127127)
@@ -150,9 +150,9 @@ it.skipIf(typeof use === 'undefined')('delayed falsy value', async () => {
150150 </ StrictMode > ,
151151 )
152152
153- await screen . findByText ( 'value: true' )
153+ expect ( await screen . findByText ( 'value: true' ) ) . toBeInTheDocument ( )
154154
155155 fireEvent . click ( screen . getByText ( 'button' ) )
156- await screen . findByText ( 'loading' )
157- await screen . findByText ( 'value: null' )
156+ expect ( await screen . findByText ( 'loading' ) ) . toBeInTheDocument ( )
157+ expect ( await screen . findByText ( 'value: null' ) ) . toBeInTheDocument ( )
158158} )
0 commit comments