Testing React Hooks

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

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

  • @swampflux
    @swampflux 3 ปีที่แล้ว +1

    Been really struggling with this stuff the past few months and this is the first time it was completely clear. Thank you.

  • @XinWongDigital
    @XinWongDigital 4 ปีที่แล้ว +4

    Enjoyed it as always. Some async ones?😉

  • @parasmanikc7341
    @parasmanikc7341 3 ปีที่แล้ว

    Thanks Harry, that was great help

  • @DeViLTh0rn
    @DeViLTh0rn 3 ปีที่แล้ว +1

    The “mycomponent” pun so bad until i couldn’t hold my burst 💀

  • @Ololololomm
    @Ololololomm 5 ปีที่แล้ว +4

    Thank you, Harry! The information about how to test react apps with hooks is really poor. We need more examples with fetching data with useEffect, and some examples with input, select etc.

    • @hswolff
      @hswolff  5 ปีที่แล้ว +1

      Yeah there's a lot to cover. Hopefully this gets you started!

    • @Gbd279
      @Gbd279 5 ปีที่แล้ว +1

      @@hswolff Any examples on how to test a Component that calls useEffect which contains an async call?

  • @tokyowalkingmap4822
    @tokyowalkingmap4822 5 ปีที่แล้ว +1

    You should do a course on hooks testing - there is basically nothing out there.

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      Anything specifically you’re curious about?

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

    Hi Harry! would be amazing if you could make a Part 2 testing also with Redux. Maybe (redux-react-hook) ? :) Thank you in advance!

    • @hswolff
      @hswolff  5 ปีที่แล้ว +1

      Oh interesting idea. I’ll add to my list of videos to make. Thank you!

    • @rudolfcicko3913
      @rudolfcicko3913 5 ปีที่แล้ว

      @@hswolff Thank you very much for your answer! I am looking forward for it ;)

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

    Incrementation means that you add one to a value so " increments by *value*" doesn't make sense.

  • @DragonByte79
    @DragonByte79 3 ปีที่แล้ว +1

    What is he saying? "My Corona" @ 3:07? The video is from 2019. Wow.... strange!

  • @guygolan3685
    @guygolan3685 4 ปีที่แล้ว

    Hi Harry. What would you recommend?
    I have a CRA app that comes with react-testing-library already using jest. Should i switch to Enzyme?

  • @JWhitty
    @JWhitty 3 ปีที่แล้ว

    could you explain why you put the callback function in the (params go here) section of the component? Is it necessary in general or just for the testing?

  • @РоманТатаринов
    @РоманТатаринов 5 ปีที่แล้ว +1

    Thanks, but it's very simple test cases. You need to create video with useReducer and methods which imports, but don't get in props

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

      Yep! Wanted to start with a simple case before getting more complicated.

  • @mikeambukadze3003
    @mikeambukadze3003 5 ปีที่แล้ว +1

    Thank You Harry. Extremely useful video =)

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      You are welcome! Glad you enjoyed!

  • @lemuelhawkson6319
    @lemuelhawkson6319 5 ปีที่แล้ว +1

    do I need to update enzyme and jest to test hooks? I keep getting invariant violation: Invalid hook call when I try to shallow render

    • @rayarama222
      @rayarama222 5 ปีที่แล้ว +3

      You need to use 'mount' instead of 'shallow' render due to a bug in React related to updating state in shallow wrappers. I believe the bug is being fixed but React@16.8.6 and lower are affected by the bug. That means apps bootstrapped with Create React App are affected (as of July 15 2019) because CRA currently uses @16.8.6.

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      Thanks for the reply Ray! 100% on point!

    • @lemuelhawkson6319
      @lemuelhawkson6319 5 ปีที่แล้ว

      @@rayarama222 Thanks!

  • @vojtasks
    @vojtasks 4 ปีที่แล้ว +1

    Yeah, testing such simple set state is simple, now do use effect with fetch...

  • @learnbit_bo
    @learnbit_bo 3 ปีที่แล้ว

    amazing, this is the way to tech something

  • @mohammaddarbandi6285
    @mohammaddarbandi6285 3 ปีที่แล้ว

    I'm sorry that I did not get acquainted with your higher education earlier ❤❤❤

  • @alanthomasgramont
    @alanthomasgramont 4 ปีที่แล้ว

    shallow() doesn't work, which makes it difficult to use React Native. Any resources you could point me to for that?

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

    Nice tutorial. I have a scenario where my useEffect depends on one of props value. In this case how can we write a test? Is it possible to write test without using enzymes? I hope you answer this ASAP :)
    Thanks in advance!

    • @rahulbera454
      @rahulbera454 4 ปีที่แล้ว +1

      react testing library

  • @Wakkyguy
    @Wakkyguy 3 ปีที่แล้ว

    Can we use shallow instead of mount?

  • @ilimavip477
    @ilimavip477 ปีที่แล้ว

    I’m literally going crazy with React Context, useReducer, Framework7, electron, SocketIO type of setup… literally got my Provider to work but can’t test it all together 😑 JSDOM keeps on complaining about things that idk

  • @AbhishekKumar-mq1tt
    @AbhishekKumar-mq1tt 5 ปีที่แล้ว +1

    Thank u for this awesome video

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      Thank you for watching!!

  • @justinstoddard4782
    @justinstoddard4782 3 ปีที่แล้ว

    It would be awesome to see a video about testing custom hook sthat use async api calls

  • @MehmetKoseDev
    @MehmetKoseDev 5 ปีที่แล้ว

    That was clear exp. mate thanks

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      Awesome! Glad to hear!

  • @compeng2013
    @compeng2013 5 ปีที่แล้ว

    can you cover this same topic but using react-testing-library?

  • @krzysztofkk6964
    @krzysztofkk6964 5 ปีที่แล้ว +1

    I always name ALL my components 'YourComponent', how did YOU know that??
    (cool & helpful video, thank you :) )

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      haha :D glad you enjoyed! thank you!

  • @mouradaouinat8721
    @mouradaouinat8721 4 ปีที่แล้ว

    Amazing stuff

    • @hswolff
      @hswolff  4 ปีที่แล้ว

      Woohoo! Thank you!

  • @EdikBulikyan
    @EdikBulikyan 5 ปีที่แล้ว

    Thank you for that video.

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      You are welcome!

  • @aerocodes
    @aerocodes 5 ปีที่แล้ว

    Hey Harry very nice one mate... listen bro do you want to code together some of these days?

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      What do you want to code?

    • @aerocodes
      @aerocodes 5 ปีที่แล้ว

      @@hswolff haha I'm not sure actually. Where are you based btw, do you have a job?

  • @wolfroad
    @wolfroad 5 ปีที่แล้ว

    I wish you did this video a month ago!

    • @hswolff
      @hswolff  5 ปีที่แล้ว

      Haha, better late than never!

    • @wolfroad
      @wolfroad 5 ปีที่แล้ว +1

      @@hswolff Could you do a video on routing and hooks?

  • @aaronmoore9936
    @aaronmoore9936 5 ปีที่แล้ว +1

    Great video man. Love your content. You should check out github.com/testing-library/react-hooks-testing-library if you haven't already. A very nice and concise way to test hooks.

    • @hswolff
      @hswolff  5 ปีที่แล้ว +1

      Yeah! I almost included that as an example too! I need more practice using it before I teach it but I love that library too!

  • @RajSingh-ts3vb
    @RajSingh-ts3vb 4 ปีที่แล้ว +1

    Why are you calling the event handler on every render... that makes no sense dude. You don't know that the count has changed on every render.

  • @gustaff.weldon
    @gustaff.weldon 5 ปีที่แล้ว +1

    Can we be just done with screaming at the start of the video? It does not make the video more cool, rather more annoying... Re: the problem with reference, you could eq. return an object with `result` property and update that in your HookWrapper, no hoisting needed.

  • @mohak1990y
    @mohak1990y 4 ปีที่แล้ว

    i did'nt

  • @alishayk374
    @alishayk374 ปีที่แล้ว

    please make your intros less enthusiastic, you scared the jesus out of me

  • @tinawhatsgood
    @tinawhatsgood 4 ปีที่แล้ว

    this much excitement to test some counter app???? what a waste of time. reserve it for when you test a real app.