Testing React useState hook

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ • 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 ua-cam.com/video/3ZR_u113e5M/v-deo.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!!

  • @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

  • @rohitbhatt7749
    @rohitbhatt7749 2 роки тому

    Great Work, Make more tutorials