@@ -52,16 +52,16 @@ test('can get elements by matching their text content', () => {
5252 </span>
5353 </div>
5454 ` )
55- expect ( queryByText ( 'Currently showing' ) ) . toBeInTheDOM ( )
56- expect ( queryByText ( 'Step 1 of 4' ) ) . toBeInTheDOM ( )
55+ expect ( queryByText ( 'Currently showing' ) ) . toBeTruthy ( )
56+ expect ( queryByText ( 'Step 1 of 4' ) ) . toBeTruthy ( )
5757} )
5858
5959test ( 'matches case with RegExp matcher' , ( ) => {
6060 const { queryByText} = render ( `
6161 <span>STEP 1 of 4</span>
6262 ` )
63- expect ( queryByText ( / S T E P 1 o f 4 / ) ) . toBeInTheDOM ( )
64- expect ( queryByText ( / S t e p 1 o f 4 / ) ) . not . toBeInTheDOM ( )
63+ expect ( queryByText ( / S T E P 1 o f 4 / ) ) . toBeTruthy ( )
64+ expect ( queryByText ( / S t e p 1 o f 4 / ) ) . not . toBeTruthy ( )
6565} )
6666
6767test ( 'get can get form controls by label text' , ( ) => {
@@ -120,7 +120,7 @@ test('totally empty label', () => {
120120test ( 'getByLabelText with aria-label' , ( ) => {
121121 // not recommended normally, but supported for completeness
122122 const { queryByLabelText} = render ( `<input aria-label="batman" />` )
123- expect ( queryByLabelText ( / b a t / ) ) . toBeInTheDOM ( )
123+ expect ( queryByLabelText ( / b a t / ) ) . toBeTruthy ( )
124124} )
125125
126126test ( 'get element by its alt text' , ( ) => {
@@ -130,7 +130,9 @@ test('get element by its alt text', () => {
130130 <img alt="finding nemo poster" src="/finding-nemo.png" />
131131 </div>,
132132 ` )
133- expect ( getByAltText ( / f i n .* n e m .* p o s t e r $ / i) . src ) . toBe ( 'http://localhost/finding-nemo.png' )
133+ expect ( getByAltText ( / f i n .* n e m .* p o s t e r $ / i) . src ) . toBe (
134+ 'http://localhost/finding-nemo.png' ,
135+ )
134136} )
135137
136138test ( 'query/get element by its title' , ( ) => {
@@ -161,14 +163,14 @@ test('query/get element by its value', () => {
161163
162164test ( 'can get elements by data-testid attribute' , ( ) => {
163165 const { queryByTestId} = render ( `<div data-testid="firstName"></div>` )
164- expect ( queryByTestId ( 'firstName' ) ) . toBeInTheDOM ( )
165- expect ( queryByTestId ( / f i r s t / ) ) . toBeInTheDOM ( )
166- expect ( queryByTestId ( testid => testid === 'firstName' ) ) . toBeInTheDOM ( )
166+ expect ( queryByTestId ( 'firstName' ) ) . toBeTruthy ( )
167+ expect ( queryByTestId ( / f i r s t / ) ) . toBeTruthy ( )
168+ expect ( queryByTestId ( testid => testid === 'firstName' ) ) . toBeTruthy ( )
167169 // match should be exact, case-sensitive
168- expect ( queryByTestId ( 'firstname' ) ) . not . toBeInTheDOM ( )
169- expect ( queryByTestId ( 'first' ) ) . not . toBeInTheDOM ( )
170- expect ( queryByTestId ( 'firstNamePlusMore' ) ) . not . toBeInTheDOM ( )
171- expect ( queryByTestId ( 'first-name' ) ) . not . toBeInTheDOM ( )
170+ expect ( queryByTestId ( 'firstname' ) ) . not . toBeTruthy ( )
171+ expect ( queryByTestId ( 'first' ) ) . not . toBeTruthy ( )
172+ expect ( queryByTestId ( 'firstNamePlusMore' ) ) . not . toBeTruthy ( )
173+ expect ( queryByTestId ( 'first-name' ) ) . not . toBeTruthy ( )
172174} )
173175
174176test ( 'getAll* matchers return an array' , ( ) => {
@@ -248,8 +250,8 @@ test('using jest helpers to assert element states', () => {
248250 const { queryByTestId} = render ( `<span data-testid="count-value">2</span>` )
249251
250252 // other ways to assert your test cases, but you don't need all of them.
251- expect ( queryByTestId ( 'count-value' ) ) . toBeInTheDOM ( )
252- expect ( queryByTestId ( 'count-value1' ) ) . not . toBeInTheDOM ( )
253+ expect ( queryByTestId ( 'count-value' ) ) . toBeTruthy ( )
254+ expect ( queryByTestId ( 'count-value1' ) ) . not . toBeTruthy ( )
253255 expect ( queryByTestId ( 'count-value' ) ) . toHaveTextContent ( '2' )
254256 expect ( queryByTestId ( 'count-value' ) ) . not . toHaveTextContent ( '21' )
255257 expect ( ( ) =>
@@ -258,21 +260,17 @@ test('using jest helpers to assert element states', () => {
258260
259261 // negative test cases wrapped in throwError assertions for coverage.
260262 expect ( ( ) =>
261- expect ( queryByTestId ( 'count-value' ) ) . not . toBeInTheDOM ( ) ,
263+ expect ( queryByTestId ( 'count-value' ) ) . not . toBeTruthy ( ) ,
262264 ) . toThrowError ( )
263265 expect ( ( ) =>
264- expect ( queryByTestId ( 'count-value1' ) ) . toBeInTheDOM ( ) ,
266+ expect ( queryByTestId ( 'count-value1' ) ) . toBeTruthy ( ) ,
265267 ) . toThrowError ( )
266268 expect ( ( ) =>
267269 expect ( queryByTestId ( 'count-value' ) ) . toHaveTextContent ( '3' ) ,
268270 ) . toThrowError ( )
269271 expect ( ( ) =>
270272 expect ( queryByTestId ( 'count-value' ) ) . not . toHaveTextContent ( '2' ) ,
271273 ) . toThrowError ( )
272-
273- expect ( ( ) =>
274- expect ( { thisIsNot : 'an html element' } ) . toBeInTheDOM ( ) ,
275- ) . toThrowError ( )
276274} )
277275
278276test ( 'using jest helpers to check element attributes' , ( ) => {
@@ -359,21 +357,21 @@ test('test the debug helper prints the dom state here', () => {
359357 </div>`
360358
361359 const { getByText} = render ( Large ) // render large DOM which exceeds 7000 limit
362- expect ( ( ) => expect ( getByText ( 'not present' ) ) . toBeInTheDOM ( ) ) . toThrowError ( )
360+ expect ( ( ) => expect ( getByText ( 'not present' ) ) . toBeTruthy ( ) ) . toThrowError ( )
363361
364362 const Hello = `<div data-testid="debugging" data-otherid="debugging">
365363 Hello World!
366364 </div>`
367365 const { getByTestId} = render ( Hello )
368366 process . env . DEBUG_PRINT_LIMIT = 5 // user should see `...`
369- expect ( ( ) => expect ( getByTestId ( 'not present' ) ) . toBeInTheDOM ( ) ) . toThrowError (
367+ expect ( ( ) => expect ( getByTestId ( 'not present' ) ) . toBeTruthy ( ) ) . toThrowError (
370368 / \. \. \. / ,
371369 )
372370
373371 const { getByLabelText} = render ( Hello )
374372 process . env . DEBUG_PRINT_LIMIT = 10000 // user shouldn't see `...`
375373 expect ( ( ) =>
376- expect ( getByLabelText ( 'not present' ) ) . toBeInTheDOM ( / ^ ( (? ! \. \. \. ) .) * $ / ) ,
374+ expect ( getByLabelText ( 'not present' ) ) . toBeTruthy ( / ^ ( (? ! \. \. \. ) .) * $ / ) ,
377375 ) . toThrowError ( )
378376
379377 //all good replacing it with old value
0 commit comments