Unit Testing in React with Jest - Mock, Snapshots and more

My Udemy Courses:
www.udemy.com/user/ghulamabba...
Git Repo link:
github.com/ghulamabbas2/react...
⚙️ Gadgets I use for Recording:
💻 Laptop - Macbook PRO M1 - 16/512
amzn.to/4eUqrSe
🎤 MIC - Samson Technologies Q2U USB/XLR Dynamic Microphone
amzn.to/3W9Z4wl
🖱️Mouse - Logitech G402 Gaming Mouse Hyperion Fury USB, Black
amzn.to/3RY4xUy
⌨️ Keyboard - Logitech K380 Multi-Device Bluetooth Keyboard
amzn.to/3RY4Fn0
🖥️ Monitor - UltraSharp 24-Inch Screen Led-Lit Monitor (U2419H)
amzn.to/4bxidN6
In this video, we will learn how to write units test in react or how to do unit testing in react with Jest.
Unit Testing is a testing method that tests an individual unit of software like a function. Unit testing for React Apps means testing an individual React Component. Unit Testing is important for React Apps, as it helps in testing the individual functionality of React components.
We will take a deep look at how to write these units. We will take two different components and write unit tests to have a better understanding.
Watch the complete video and if you face any issues let me know is the comment section.
Like, Subscribe, and Share. Cheers!

Пікірлер: 23

  • @syedsadath4918
    @syedsadath49189 ай бұрын

    Subscribed 👍🏼, please create more videos on react testing with Jest and react testing library.

  • @hkhsm359
    @hkhsm3599 ай бұрын

    Nice and very help full video. Thanks for sharing.

  • @sundayuchegbu2060
    @sundayuchegbu2060 Жыл бұрын

    Awesome... quite helpful

  • @codingwithabbas

    @codingwithabbas

    Жыл бұрын

    Glad it helped

  • @cherukupalliramanjaneyulu4598
    @cherukupalliramanjaneyulu45983 ай бұрын

    Thank you so much sir

  • @user-ls5gp4it7z
    @user-ls5gp4it7z11 ай бұрын

    how to run this test code with sonar-scanner

  • @ScottStrong
    @ScottStrong Жыл бұрын

    The method of getting the elements for comments has changed since this video's release. This was giving me an error until I made the following suggested change: const comments = await waitFor(() => screen.getAllByTestId("comment")); -> replaced with -> const comments = await screen.findAllByTestId("comment"); A very minor change, but it fixed an error that was appearing as a result. Also, this tutorial was awesome and super helpful! Thanks for making it!

  • @deeksha5626

    @deeksha5626

    Жыл бұрын

    it has to be replaced with const comments = await screen.findAllByTestId("comment");

  • @premprakash6673
    @premprakash6673 Жыл бұрын

    Very helpful video. Could you please make videos on jest and react testing library which includes concepts like jest.spyOn, .mockImplementation, .resolves, .rejects, promise, .mockResolvedValueOnce etc. I am not finding any tutorials on this and in my project these things are heavily used

  • @codingwithabbas

    @codingwithabbas

    Жыл бұрын

    Hi Prem, I will do it soon. I know these concepts or functions are heavily used in Jest.

  • @061_suryak4
    @061_suryak4 Жыл бұрын

    hi, i got error like could not find react-redux context value; please ensure the component is wrapped in a but i also wrapped by provider within store and i change old to latest version please gave me a any solution

  • @codingwithabbas

    @codingwithabbas

    Жыл бұрын

    Is you App component wrapped in Provider?

  • @user-zs5no2mq3r
    @user-zs5no2mq3r Жыл бұрын

    Hi, How can i test when data coming from API instead dummy data

  • @codingwithabbas

    @codingwithabbas

    Жыл бұрын

    Will make a details video on that as well.

  • @dhruvsakariya3129
    @dhruvsakariya3129 Жыл бұрын

    SyntaxError: Cannot use import statement outside a module I am getting this error Please help 😥

  • @codingwithabbas

    @codingwithabbas

    Жыл бұрын

    Have you added this test script in package.json file? "test": "react-scripts test --transformIgnorePatterns node_modules/jest/bin/jest.js/",

  • @dhruvsakariya3129

    @dhruvsakariya3129

    Жыл бұрын

    @@codingwithabbas It worked Thank you 🙏

  • @chd6085
    @chd6085 Жыл бұрын

    hey, how are you getting autocomplete on jest...?

  • @codingwithabbas

    @codingwithabbas

    Жыл бұрын

    Check is this package (@types/jest) present in your package.json file.

  • @chd6085

    @chd6085

    Жыл бұрын

    @@codingwithabbas no its not there... where should I put this...? should it be inside any other object or at the root of the package.json object....?

  • @codingwithabbas

    @codingwithabbas

    Жыл бұрын

    Install it as dev dependency.

  • @Dev-Phantom
    @Dev-Phantom2 ай бұрын

    cool

  • @thomaselster8629
    @thomaselster8629 Жыл бұрын

    𝓅𝓇𝑜𝓂𝑜𝓈𝓂