React Testing #1

 

 Basic test type

what not to test 

RTL Queries


 

 The dot signifies suffix

 GetByRole 

 

 

 

 FE created before hand

 

 

 How do I know role of each componet ?

https://www.w3.org/TR/html-aria/#docconformance

getbyRole -options

However, if multiple elemet with same role than error

 

 To fix this we use options

 

 Now test verifies

 

 Works for bio as well (Here name signifies label content)

Check if heading is present by test

 

 Got an error when we do this

 To Fix this

Niw the test passes

We also want to make sure first heading is h1 and second is h2


 Other role

 getByLabelText

 

Here instead of finding them by role we are finding by label


 Wrapper Labels

 

 Plz intenionally fail the test as well as always test pass is common occurence while testing

 Errro as multiple elemet have the same text as name

we are fixing it by adding selector element

 getByPlaceholderText

 

 

 

 test passes as it is present

 getByText

Typically we use for span,div and p element


 

 It also excepts accepts an option like getByLabel


getByDisplayValue

 

 

 Test passes

use for form control value

 

 

 

 

 

 

 

 

 

 

 

 

h

 

Comments

Popular posts from this blog

Form Part 2

Event mini project by Thapa#33

De-mystifying 'this' keyword of Javascript