React Testing #4

 # Testing in custom react hooks

 

 

 Now here is a problem if we directly use old method to get custom hook value. As, hook is not a dom element so it will throw an error. So, what we can do is use renderHook instaed of default render option

 Now after using it in above way our test passes

 

 we are using initalcount in object becayse type we assigned is object

 Act Utility

Check increment and decrement

 Now the count should be 1 but it is not so it throws an error

 We are directly calling increment so act not works ...knowmore by wathcing video again or see documentaion

 

 Codes that causes state update can't be wrapped by act so we need to manually do it


b

Comments

Popular posts from this blog

Form Part 2

Event mini project by Thapa#33

De-mystifying 'this' keyword of Javascript