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

  Рет қаралды 18,053

Coding With Abbas

Coding With Abbas

Күн бұрын

My Udemy Courses:
www.udemy.com/...
Git Repo link:
github.com/ghu...
⚙️ 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!

Пікірлер: 27
@syedsadath4918
@syedsadath4918 11 ай бұрын
Subscribed 👍🏼, please create more videos on react testing with Jest and react testing library.
@hkhsm359
@hkhsm359 11 ай бұрын
Nice and very help full video. Thanks for sharing.
@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.
@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");
@sundayuchegbu2060
@sundayuchegbu2060 Жыл бұрын
Awesome... quite helpful
@codingwithabbas
@codingwithabbas Жыл бұрын
Glad it helped
@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?
@BalasubramaniamM-d2r
@BalasubramaniamM-d2r Жыл бұрын
how to run this test code with sonar-scanner
@surajkhadse-c3f
@surajkhadse-c3f Жыл бұрын
Hi, How can i test when data coming from API instead dummy data
@codingwithabbas
@codingwithabbas Жыл бұрын
Will make a details video on that as well.
@cherukupalliramanjaneyulu4598
@cherukupalliramanjaneyulu4598 6 ай бұрын
Thank you so much sir
@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-Phantom 5 ай бұрын
cool
@thomaselster8629
@thomaselster8629 Жыл бұрын
𝓅𝓇𝑜𝓂𝑜𝓈𝓂
@mihirraval2174
@mihirraval2174 Ай бұрын
Can you give me your mail id I have one question!! My tsx component not rendering 😢
@codingwithabbas
@codingwithabbas Ай бұрын
Component is not rendering? Can you see any error?
@mihirraval2174
@mihirraval2174 Ай бұрын
@@codingwithabbas yes that's why I have to send some code pictures and also explain why I am getting error
@mihirraval2174
@mihirraval2174 Ай бұрын
Because that is my project which will be deploy on 21 -8+ -2024 can you help me then must help ??
Mocking Asynchronous Functions with Jest
21:50
Swashbuckling with Code
Рет қаралды 71 М.
Testing In React Tutorial - Jest and React Testing Library
21:28
Inside Out 2: ENVY & DISGUST STOLE JOY's DRINKS!!
00:32
AnythingAlexia
Рет қаралды 18 МЛН
버블티로 부자 구별하는법4
00:11
진영민yeongmin
Рет қаралды 16 МЛН
Mock vs Spy in Testing with Jest: Which is Better?
25:12
Dev tips by MoHo
Рет қаралды 11 М.
Laravel vs Rails for Javascript developers
19:50
Sam Lewis
Рет қаралды 5 М.
Stop Writing So Many Tests
10:02
Web Dev Simplified
Рет қаралды 91 М.
React Testing Tutorial (Jest + React Testing Library)
22:16
Kris Foster
Рет қаралды 254 М.
Fast Unit Testing With Vitest
1:21:09
Learn With Jason
Рет қаралды 32 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 164 М.
Modern Data Fetching in React (Complete Guide)
16:41
Cosden Solutions
Рет қаралды 55 М.
Next.js with React Testing Library, Jest, TypeScript
25:04
Dave Gray
Рет қаралды 66 М.
Inside Out 2: ENVY & DISGUST STOLE JOY's DRINKS!!
00:32
AnythingAlexia
Рет қаралды 18 МЛН