React Testing #2
From part 28
Create a folder skills
Here we cant use getbyrole as it has multiple element (list items)
Textmatch
Here,we are conditonally rendering button
It means login button is present in the ui
We exactly want this
However there is an error
Now test pass
Summary: When we want to ensure that an element is not present than we use queryby or queryallby set of classes
now check for start learning button
Test passes after doing this
The drfault timeout is 2000 ms but we can change it
debugging a test
When we change start learn the test fails
It can be easily seen and also dom tree is there to help us debug
To get dom tree we can use debug method
debug before start lerning not present and afetr present
to get log of views
helps find logs in getbyroles method
Testing playground chrome extension
Hiver over query to find best testing method
Testing user interaction
user-event is imported by default
minor-uissue->cra use 13v but 14v is now avail...so if it is this case than update
Handling mouse interactions
Bith the element present so the test passes
This also passes
next import user-event
Our test passes
hiver and unhover also use for tooltip
Dont use unless absolutely req as not necessary
Keyboard interactions
Test the input value using rtl
1) get amount ip
2) user type
3) check if type match
4) next click
5) check if heading match
1) first get all 3 elements
2) yser tab focuse goes to increment btn
3) user tab focus goes to spinner btn
4) usertab focus to amount btn
can use label or value -> so 1 and 3 is true
Testing Providers
m
Comments
Post a Comment