Testing React useState hook

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 8

  • @rohitbhatt7749
    @rohitbhatt7749 2 ปีที่แล้ว +2

    I did not expect a video with less than 1k views to clear all my doubts that were not resolved after watching so many tutorials.

  • @evangelosleventelis8073
    @evangelosleventelis8073 2 ปีที่แล้ว

    Hello Timothy,
    and if count was not in the dom but was a state that we were passing to other component or we were using for another functionality, how would we test that value changed?

    • @timothyamo
      @timothyamo  2 ปีที่แล้ว

      Thanks for the question. I made a video giving a general idea of how to go about testing state in this particular scenario. Here's the link th-cam.com/video/3ZR_u113e5M/w-d-xo.html
      If there is any more questions or things that you aren't clear about, do let me know. And thanks very much for watching the video

    • @evangelosleventelis8073
      @evangelosleventelis8073 2 ปีที่แล้ว

      @@timothyamo Thank you very much Timothy!! Keep it up!!

  • @rohitbhatt7749
    @rohitbhatt7749 2 ปีที่แล้ว

    Great Work, Make more tutorials

    • @timothyamo
      @timothyamo  2 ปีที่แล้ว

      Thank you, I will.

  • @toomanyarguments
    @toomanyarguments 2 ปีที่แล้ว

    what if i have a component that is getting a setState func as a prop. how can i mocking a setState func?

    • @timothyamo
      @timothyamo  2 ปีที่แล้ว

      You will need to use the jest mock function i.e. jest.fn() and pass it as a prop to the component. Take a look at this gist gist.github.com/timdereaper1/901435748f9fdca68afca053fa3b1cef