React Unit Testing Tutorial With React Testing Library and Vitest React

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ส.ค. 2024
  • In this React testing tutorial you will learn how to test React correctly. As React doesn't give us any testing tools we will use React testing library and Vitest in order to get an easy testing setup.
    TIMESTAMPS
    0:00 Introduction
    1:39 Initial project
    2:24 Vitest React
    3:48 Basic component testing
    9:26 Testing React props
    12:40 Testing React callbacks
    14:56 React mock dependencies
    17:06 Testing plain functions
    ► CHECK MY COURSES - monsterlessons-academy.com/co...
    MOST POPULAR COURSES
    ► Building real project with Angular + NgRx - monsterlessons-academy.com/co...
    ► Building real NestJS API - monsterlessons-academy.com/co...
    ► Javascript interview questions - monsterlessons-academy.com/co...
    ► Angular Interview Questions monsterlessons-academy.com/co...
    ► Building real fullstack project - monsterlessons-academy.com/co...
    ► Mastering Git - monsterlessons-academy.com/co...
    ► Mastering Docker and Docker Compose - monsterlessons-academy.com/co...
    ► Building real project with React Hooks - monsterlessons-academy.com/co...
    ► Building real project with Vue + Vuex - monsterlessons-academy.com/co...
    FOLLOW ME
    ► TWITTER - / monster_lessons
    ► INSTAGRAM - / monsterlessonsacademy
    ► TIKTOK - / monsterlessonsacademy
    REFERENCES
    ► Source code - github.com/monsterlessonsacad...

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

  • @garikmelqonyan6011
    @garikmelqonyan6011 3 หลายเดือนก่อน +2

    Good job, bro!
    Btw, you said you have solved the issue with `SyntaxError: Cannot use import statement outside a module jest`.
    Can you pls tell how you have done it?
    There is tons of info about it but none of them solves the issue...

  • @devyadav0399
    @devyadav0399 3 หลายเดือนก่อน +1

    Really helpful, keep up the good work!

  • @kmdoll
    @kmdoll หลายเดือนก่อน

    Thanks for the video. Very helpful. Just curious, when you code personal projects, do you start with tests first or do you start with writing code first? Thanks.

  • @peshutanpavri1599
    @peshutanpavri1599 4 หลายเดือนก่อน

    Very good video, Thank you for sharing. I was thinking, since Cypress has its Component testing, is it not possible to just use Cypress ?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  4 หลายเดือนก่อน +1

      You kind of can, but it is not a replacement for normal unit testing. Cypress just lacks flexibility of unit testing.

    • @peshutanpavri1599
      @peshutanpavri1599 4 หลายเดือนก่อน

      Thank you so much@@MonsterlessonsAcademy for getting back to me. Yeah that makes sense, I am just trying to get the most complete setup without excess dependencies,
      I guess I will use this for Unit tests, and possibly for component too, then cypress just for E2E

  • @haidarmuhammadnaufal160
    @haidarmuhammadnaufal160 8 วันที่ผ่านมา

    I cannot insert my component inside render(). It's said that my component is a type even thought it isn't

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  8 วันที่ผ่านมา

      Unfortunately I help with code debugging only in the paid courses as it takes a lot of time and effort.

  • @waleedsharif618
    @waleedsharif618 9 หลายเดือนก่อน

    Does it work normally if we use React testing library + jest + vite and not vitest ?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  9 หลายเดือนก่อน

      Yes obviously

    • @niloben659
      @niloben659 6 หลายเดือนก่อน

      @@MonsterlessonsAcademy It's not obvious, it's a legitimate question. I was wondering the same thing

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  6 หลายเดือนก่อน +1

      @@niloben659 Sorry, when I', writing code I always do it so it works for people in different os, use cases etc. This is why for me it is obviously :)

    • @niloben659
      @niloben659 6 หลายเดือนก่อน

      @@MonsterlessonsAcademy No problem and thanks for the video

  • @alishettima9788
    @alishettima9788 หลายเดือนก่อน

    Nice presentation, but you are little bit fast with talking. Please move slowly, so that people can follow with you along because your presentation is excellent.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  หลายเดือนก่อน

      Thank you for the feedback. Meanwhile you can slow down the video if it is too fast for you.

    • @Its-InderjeetSinghGill
      @Its-InderjeetSinghGill 12 วันที่ผ่านมา

      @@MonsterlessonsAcademyNice humour 😂😂😂

  • @ice-sugar.
    @ice-sugar. 7 หลายเดือนก่อน +1

    Spasibo