How to use Vitest with Jest-DOM and React Testing Library

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • In this next Code With Me series, I'll be experimenting with the world of Test Driven Development.
    Before we get started, we need to set up our environment for testing. I have decided to use Vitest, since I am an avid user of Vite. I don't want to use Create-React-App even though the testing is ready to go. I find CRA bloated and slow, but I still want to use the awesome tools provided by React Testing Library and Jest-dom.
    In this video, we walk through the steps required to set up Vitest with JSDOM, React Testing Library and Jest-DOM so we can test our React components.
    Vite: vitejs.dev/
    Vitest: vitest.dev/
    Vitest Example Library: github.com/vit...
    Vitest React Testing Lib Example: github.com/vit...

Комментарии • 59

  • @DrumkitCodes
    @DrumkitCodes 2 месяца назад +2

    Thanks so much for the tutorial! I couldn't figure out how to get vitest working before, I really appreciate how you went through the full setup and explained why we were setting certain things to certain values. Can't wait to see more in your TDD series

  • @fatasefer
    @fatasefer 11 месяцев назад +7

    Finally, exactly what I was looking for. Simple and straight to the point. Thank you so much!

  • @vponochovny
    @vponochovny Месяц назад

    Really nice to link the vitest examples. It helped me much cause my setup was failing for some strange reasons

  • @paulgasbarra
    @paulgasbarra 4 месяца назад +4

    This is the most helpful thing.

  • @user-bx5bn5gn9l
    @user-bx5bn5gn9l 8 месяцев назад +1

    I really needed this one, I am switching to typescript and react-vite now and I am struggling with testing with jest library with typescript. This one is easier to configure and faster. You should continue this TDD serie dude, you will help a lot of young, beginners, junior developers like me

  • @BenHuxford
    @BenHuxford Год назад +2

    great video 😊 one thing to note is you install the "jsdom" package at 4:50. In my setup this module is not needed when using testing-library's "jest-dom" because they both perform the same functionality of mimicking the browser DOM

  • @jeff-creations
    @jeff-creations Месяц назад

    Nice presentation and super useful! Thank you so much, my component tests don't error out now. Keep up the great work!

  • @JMIKAEL6
    @JMIKAEL6 11 месяцев назад

    After 3 hours trying to configure i found your video and solve it in 10min.
    Thank you so much!

    • @ericwinkdev
      @ericwinkdev  11 месяцев назад

      So glad that it helped!

  • @Prathap_SK
    @Prathap_SK 6 месяцев назад

    To be honest, It is first video in vitest. It is pretty straightforward to go the content. Thank for clear view

  • @altamashkhan4858
    @altamashkhan4858 10 месяцев назад +1

    Thank you for posting this video.

  • @ramioooz
    @ramioooz 11 месяцев назад +1

    This is a very important video. Thank you for sharing.

  • @ЭзизК
    @ЭзизК 2 месяца назад +1

    I have a problem, MISSING DEPENDENCY Cannot find dependency 'jsdom'
    Should I install it as devdepend?

  • @wellingtonostemberg7585
    @wellingtonostemberg7585 11 месяцев назад +1

    I loved that! It´s exactly what i was looking for. Thank you!

  • @abhijitmondalabhi2146
    @abhijitmondalabhi2146 5 месяцев назад +2

    Most of the things are not working any more. I think they already changed the setups little bit.

  • @mrluckyuncle
    @mrluckyuncle 10 месяцев назад +1

    Excellent. Just what I was looking for. One little thing... it would be nice if the video was available in a higher resolution.

  • @tobibada6443
    @tobibada6443 Месяц назад

    I was so giddy after hearing the name😂. Randomly chose the video and heard a name from my best tech podcast🤭🤭

  • @keifer7813
    @keifer7813 9 месяцев назад

    Thanks a ton for this. Nice and easy setup, first time using vitest for me

  • @FingerTipWisdom
    @FingerTipWisdom 2 месяца назад

    Thanks lot brother save me lot of time !!!

  • @ThaRealIansanity
    @ThaRealIansanity Год назад

    Great start. I'm taking a vitest course and want to learn to use it with both react and vue. Thank you

  • @ahoymatey1234
    @ahoymatey1234 Год назад +1

    I found an alternative to adding those reference types by adding this to my tsconfig
    "types": [
    "vite/client",
    "vitest/globals"
    ]

  • @faruzzy
    @faruzzy 7 месяцев назад

    Thanks for walking us through this!

  • @kakun7238
    @kakun7238 11 месяцев назад +1

    but how do i test for huge components i am stuck

  • @coderboyakash5853
    @coderboyakash5853 6 месяцев назад

    This is really helpful for me buddy thanks so much

  • @kikevanegazz325
    @kikevanegazz325 4 месяца назад

    Brother, great tutorial. I like it because it's spot on.

  • @SteelGamePad
    @SteelGamePad Год назад +1

    great explanation, can't wait for part 2

  • @WitchingHr
    @WitchingHr Год назад +1

    thank you so much man. this helped a lot

  • @kedaraksym12
    @kedaraksym12 11 месяцев назад

    Thanks for this manual, I appreciate that ;)

  • @bornback4524
    @bornback4524 Год назад

    Thx for helping to understand and easy to implement 🙂

  • @pranshubasak8796
    @pranshubasak8796 9 месяцев назад

    You are really a saviour

  • @davidjnevin
    @davidjnevin 7 месяцев назад

    Life saver!

  • @user-mr3yr9qe6d
    @user-mr3yr9qe6d 11 месяцев назад

    clear and helpful. thank you very much

  • @1haker
    @1haker 8 месяцев назад

    ABSOLUTLY AMAZING :)

  • @raj.blazers
    @raj.blazers Год назад

    Much thanks man! Helped a lot. 🎉

  • @simonprato9666
    @simonprato9666 6 месяцев назад

    Thanks men, very clear!

  • @manavjethani4118
    @manavjethani4118 7 месяцев назад

    This is really great, i am able to setup vitest with your help, although i am stuck with this error `TypeError: Class extends value undefined is not a constructor or null` while using amcharts4 in our project, wanted to ask do we have to do add any config to allow `Class extends` syntax?

  • @mahanmashoof1989
    @mahanmashoof1989 Год назад

    great intro to vitest! thanks

  • @gustuckit2052
    @gustuckit2052 Год назад

    i get an error saying "no test files found", very weird... :( (im not using ts)

  • @walidaguib3944
    @walidaguib3944 6 месяцев назад

    Thanks a lot😍

  • @brortiz
    @brortiz 8 месяцев назад

    Great video, thanks!

  • @somajuice666
    @somajuice666 3 месяца назад

    THANKS

  • @rannue2921
    @rannue2921 10 месяцев назад

    Thank you so much!!!

  • @splat_bang
    @splat_bang 9 месяцев назад

    Thankyou so much!

  • @Anthony-wg7fn
    @Anthony-wg7fn Год назад

    Can you do this same thing with the T3 stack?

  • @guillermoemmanuelsanchezin1664

    Hi! Would you be so kind to try using vitest with MSW, I would really appreciate it!

  • @yatinpatel4123
    @yatinpatel4123 Год назад

    yes, there is no tutorial available like this set for react + vite for testing library.

  • @dolevdo
    @dolevdo Год назад

    thank you a lot!

  • @v1r47
    @v1r47 Год назад

    FYI: Vitest 0.33+= requires at least node16 to run properly.

  • @booi_mangang
    @booi_mangang Год назад

    Hey, great video.
    I've a question. What if you are not using typescript. what changes will there be from your guide?

    • @ericwinkdev
      @ericwinkdev  Год назад +3

      Thanks for checking it out! If you're not using typescript, there's no tsconfig file, and the only differences should be with the file extensions. Rather than .ts and .tsx, you'll use .js and .jsx respsectively.
      If anything goes wonky let me know and I'll do my best to help out!

    • @booi_mangang
      @booi_mangang Год назад +2

      @@ericwinkdev thanks for the reply.
      I’d figured it out.
      your video helped.

    • @joelkomieter6557
      @joelkomieter6557 Год назад

      @@ericwinkdev Creating that jsconfig file won't have any of what tsconfig,json has. What do I need to do about that?

  • @Gabriel-kl6bt
    @Gabriel-kl6bt 5 месяцев назад

    Good. Just why isn't Code suggesting methods from the testing libs?