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
Subscribed 👍🏼, please create more videos on react testing with Jest and react testing library.
Nice and very help full video. Thanks for sharing.
Awesome... quite helpful
@codingwithabbas
Жыл бұрын
Glad it helped
Thank you so much sir
how to run this test code with sonar-scanner
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
Жыл бұрын
it has to be replaced with const comments = await screen.findAllByTestId("comment");
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
Жыл бұрын
Hi Prem, I will do it soon. I know these concepts or functions are heavily used in Jest.
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
Жыл бұрын
Is you App component wrapped in Provider?
Hi, How can i test when data coming from API instead dummy data
@codingwithabbas
Жыл бұрын
Will make a details video on that as well.
SyntaxError: Cannot use import statement outside a module I am getting this error Please help 😥
@codingwithabbas
Жыл бұрын
Have you added this test script in package.json file? "test": "react-scripts test --transformIgnorePatterns node_modules/jest/bin/jest.js/",
@dhruvsakariya3129
Жыл бұрын
@@codingwithabbas It worked Thank you 🙏
hey, how are you getting autocomplete on jest...?
@codingwithabbas
Жыл бұрын
Check is this package (@types/jest) present in your package.json file.
@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
Жыл бұрын
Install it as dev dependency.
cool
𝓅𝓇𝑜𝓂𝑜𝓈𝓂