React Testing Tutorial (Jest + React Testing Library)

  Рет қаралды 260,765

Kris Foster

Kris Foster

Күн бұрын

Пікірлер: 134
@marciocamollez7062
@marciocamollez7062 2 жыл бұрын
Simply the best explanation from entire KZbin. I'm studying react from 2 years and test library was the worst part to find some good videos. Congrats!
@andersonsimeon4172
@andersonsimeon4172 10 ай бұрын
For a 3 years ago video, this is high quality staright to the point content. Thanks Man
@SoftwareSimplified-Dtons
@SoftwareSimplified-Dtons Жыл бұрын
Thank you Kris for the wonderful learning videos . Just a small suggestion. The test was failing with '' so at 16:44 please change from expect(todoElement).toContainHTML(''); to expect(todoElement).toContainHTML('strike');
@skyhawksp
@skyhawksp 3 жыл бұрын
The most useful react jest testing tutorial video currently on KZbin. Thank you!
@christonit6895
@christonit6895 3 жыл бұрын
Uff thanks man! I have been all day reading the jest and react docs and wasn't understanding how to use these techs XD you just teched me how to properly unit test my UI lib.
@KrisFoster1
@KrisFoster1 3 жыл бұрын
Glad you enjoyed the video!
@peacekper
@peacekper Жыл бұрын
Thank you so much for this tutorial! I would agree with the other comments too about seeing a more involved testing suite using a state library. But this was by far the best video I've seen on using jest. Keep the videos coming
@JuaNeMe
@JuaNeMe 3 жыл бұрын
Excellent video! I have been waiting a video like this with React Testing in an useful way for a long time.
@KrisFoster1
@KrisFoster1 3 жыл бұрын
That's great, thank you for the feedback @juan ocho!
@seriouslee4119
@seriouslee4119 Жыл бұрын
Bru, your voice is so soothing. I'm rewatching this video tonight instead of ASMR lol.
@arunimaroy4383
@arunimaroy4383 Жыл бұрын
toContainHtml method expects to pass html tag as a string without tag notaion so you need to replace '' with 'strike'.
@carlosg8716
@carlosg8716 2 жыл бұрын
Excellent video. I went from zero to added to my projects in 22 minutes and 15 seconds
@vadirajkanakagiri5028
@vadirajkanakagiri5028 2 жыл бұрын
I'm getting the error as SyntaxError: Cannot use import statement outside a module, can you please help me with this
@himallimbu007
@himallimbu007 3 жыл бұрын
toContainHTML function is not working properly, can you please help?
@khandoor7228
@khandoor7228 3 жыл бұрын
please do more with testing!
@BarbarosYurttagul
@BarbarosYurttagul 8 ай бұрын
Hi Kris, thanks for the video. 21:26 How did you manage to reduce the test execution speed from 2+ seconds to 0.666 seconds? I did the same steps but mine didn't change.
@martinharyanto4465
@martinharyanto4465 Жыл бұрын
Hi Kris ! thanks for explanation, I know this video is 2 years old, is it possible for you to re-explain it with current state of Jest + React Testing Library? Probably some improvement here and there? And maybe you could help to explain about testing user event + mocking child component inside the component being tested. Thanks ! This is a very simple and great tutorial 👍
@rupeshmody8901
@rupeshmody8901 Жыл бұрын
Very simple and so far the best. Thank you.
@EminoMeneko
@EminoMeneko 3 жыл бұрын
Nice quick start.
@nusskugeldingsi
@nusskugeldingsi 2 жыл бұрын
Nice overview of testing with Jest in React! BTW the Todo component inside the map loop is missing a key prop. ;)
@I3uzzzzzz
@I3uzzzzzz 2 жыл бұрын
ur life is missing a dad ;)
@flying-musk
@flying-musk 6 ай бұрын
12:10 is tag still used for now?
@mahmoudhamdy819
@mahmoudhamdy819 Жыл бұрын
thank you so much for great and brief react test explanation
@chenyangwang1930
@chenyangwang1930 2 жыл бұрын
Perfect tutorial! Really easy to understand
@saraswathijampala510
@saraswathijampala510 2 жыл бұрын
HI.............the node version u used is 14 r 16........? Please share me i tried in both version 14 and 16 but its not working.
@HeshamElQuerm
@HeshamElQuerm 3 жыл бұрын
Good video, but why did you `mock` the props in the test file? Isn't there a more elegant way to get the real props that are passed to the component?
@jackstorm777
@jackstorm777 2 жыл бұрын
Excellent tutorial, lots of good info in 20 minutes!
@danieltkach2330
@danieltkach2330 2 жыл бұрын
I'm using Vite and not CRA, so the script for test does not exist, how do I set it up?
@gnumanoj
@gnumanoj 3 жыл бұрын
most useful video so far ! :) Thank you!
@josephcobbinah5412
@josephcobbinah5412 2 жыл бұрын
Great stuff man!!
@gmmkeshav
@gmmkeshav Жыл бұрын
what if we want to have more folders in __tests__ ?
@joseff5998
@joseff5998 Жыл бұрын
Thanks for clear and simple explanation.
@awefawefwaef
@awefawefwaef 2 жыл бұрын
what window manager are you using?
@patrickackom952
@patrickackom952 2 жыл бұрын
how do you test apps with usecontext and api calls in them
@jeff2000wu
@jeff2000wu Жыл бұрын
getting an error for this line: import renderer from 'react-test-renderer'; I install the package by npm install react-test-render , anyone know.
@MietekPomywacz
@MietekPomywacz Жыл бұрын
Very good video, explained in a simple way :)
@maxdev6347
@maxdev6347 11 ай бұрын
Which node version you use
@PilipalaOnEarth
@PilipalaOnEarth 5 ай бұрын
Thank you! It's very helpful to me.
@zaw_w_lwin
@zaw_w_lwin 3 жыл бұрын
The usual flow for TDD is to write the test first, watch it fail, and make a minimal effort to get it right and then refactor. But anyway, greate video.
@KrisFoster1
@KrisFoster1 3 жыл бұрын
Thank you for the feedback @Zaw W. Lwin, TDD is just one approach to take. This tutorial is not on TDD but just on how to test react components.
@137dylan
@137dylan 3 жыл бұрын
@@KrisFoster1 Even Kent Dodds said he rarely goes full TDD and prefers to use a more iterative approach
@jackstorm777
@jackstorm777 2 жыл бұрын
TDD is an unattainable ideal, like world peace or eternal youth, it's nice to think about but will never EVER happen :)
@timdanielewski8036
@timdanielewski8036 Жыл бұрын
​@@jackstorm777oh it's real! Maybe they call it extreme programming because it's extremely rare. I stumbled into a team of 8 developers that pair program and swap partners everyday. Not one line of code was written with out a test existing first. One of the funnest things I've ever been a part of.
@adityanair1001
@adityanair1001 3 жыл бұрын
Thanks bruh ❤️ Can u make more of these vedios How how to test for the data in a component which we r getting from api.
@aanandantma9573
@aanandantma9573 3 жыл бұрын
Are you using any extension for jest intellisense?
@mybaby2262
@mybaby2262 2 жыл бұрын
How to write a test cases for big component lets say I have component with big business logic how could I write test cases for that
@aprimic
@aprimic 3 жыл бұрын
in what circumstance will the snapshot not match?
@lyndontan1561
@lyndontan1561 3 жыл бұрын
Perfect time and a perfect example thank you!!!! from PH please do more sample like using hooks State T.I.A
@KrisFoster1
@KrisFoster1 3 жыл бұрын
Thank you for the feedback!
@sureshanands
@sureshanands 3 жыл бұрын
Bro can yu make videos for async methods RTL testing. Some other examples which helps real time project experience. This video is also good . If you make those tht would be best ❤️👍
@smhmkkh
@smhmkkh 3 жыл бұрын
Thank you, that was great. The only part i didn’t understand was what is snapshot
@damo190
@damo190 3 жыл бұрын
Thanks for this video bro. Will u start a video series on Reactjs testing just like using, mocha, chai, cypress, knightwatchJs, jasmine, karma, react testing library, etc?
@KrisFoster1
@KrisFoster1 3 жыл бұрын
I made some videos a while back on some of those technologies: cypress - m.kzbin.info/www/bejne/raCsZWxmfbeAaZY mocha/chai - m.kzbin.info/www/bejne/fHyypKeIp9yHa9k
@poenaeco
@poenaeco 3 жыл бұрын
What is the extension you are using in the console? Thanks for the tutorial btw.
@poenaeco
@poenaeco 3 жыл бұрын
I mean for the GIT.
@KrisFoster1
@KrisFoster1 3 жыл бұрын
Hi @poenaeco, it's called ohmyzsh. I find it very useful. Here's a link with steps to install ohmyz.sh/
@poenaeco
@poenaeco 3 жыл бұрын
@@KrisFoster1 Thanks for the reply.
@gina7898
@gina7898 2 жыл бұрын
This was so helpful. Thank you!
@alainhonorekubwayo8819
@alainhonorekubwayo8819 2 жыл бұрын
Excellent tutorial!
@harelweingarten
@harelweingarten Жыл бұрын
Great tutorial , TNX.
@MrAndykofi
@MrAndykofi 3 жыл бұрын
Excellent, thanks a lot, was good to watch.
@ainneo
@ainneo 3 жыл бұрын
it there a git repo for this?
@554-manjushriparkhe4
@554-manjushriparkhe4 2 жыл бұрын
Thank you so much for this vedio great vedio
@parid0khtt
@parid0khtt 3 жыл бұрын
Hi, thank you for this video, but expect(todoElement).toContainHTML('') is not working seems it should be expect(todoElement).toMatchSnapshot('');
@filcondrat
@filcondrat 2 жыл бұрын
yep
@Shaktish-kumar
@Shaktish-kumar 2 жыл бұрын
expect(todoElement).toContainHTML('strike'); This worked, use only the html tag name
@lekkyjayz6294
@lekkyjayz6294 3 жыл бұрын
Can you make a tutorial about react redux unit testing?
10 ай бұрын
awesome content , thank you very much your time.
@mauroinde
@mauroinde 2 жыл бұрын
new subscriber, clear class
@akunduru4
@akunduru4 3 жыл бұрын
Thanks for the video. How do we get that back quote in the VSC in the data-testid={'todo-${id}'} ?
@MohamedElamir3
@MohamedElamir3 3 жыл бұрын
the button under the Esc button
@nicolasgomez5207
@nicolasgomez5207 2 жыл бұрын
``
@marvinotieno2194
@marvinotieno2194 11 ай бұрын
This video is really good
@LeanneLacey-Byrne
@LeanneLacey-Byrne Жыл бұрын
Nice hi Kris, From Ireland too
@grumly85
@grumly85 2 жыл бұрын
I've got pink panther in my head now with all these 'todo, todo, todo,...' Nice tutorial still
@KrisFoster1
@KrisFoster1 2 жыл бұрын
Thank you!
@sukhsingh7057
@sukhsingh7057 2 жыл бұрын
Great guide!
@jaceborg
@jaceborg 3 жыл бұрын
Great video, really well explained, thanks :)
@spytyler
@spytyler 3 жыл бұрын
Great video. Very helpful
@dinidulochana3295
@dinidulochana3295 3 жыл бұрын
Great content!! Thank you.
@KrisFoster1
@KrisFoster1 3 жыл бұрын
Thank you!
@marcelhumes1360
@marcelhumes1360 2 жыл бұрын
Thank you Kris.
@cloudsss83
@cloudsss83 Жыл бұрын
you should create more tuts... you`re good. thanks
@bautista-cutraro
@bautista-cutraro 3 жыл бұрын
Great video!
@cristoslaher
@cristoslaher 2 жыл бұрын
Great! Really helpful
@Leo-bl3ge
@Leo-bl3ge 3 жыл бұрын
Why does my simple tests take so long? A simple expect(true).toBe(true) takes(2ms) but Time was 3s (yours was 1s) Edit: I was able to make it 1.9s with --maxWorkers=50%, but idk if there's more to do
@charithamila9194
@charithamila9194 3 жыл бұрын
Thanks a lot. Very helpful
@oliver1231033
@oliver1231033 3 жыл бұрын
awesome content, thank you!
@KrisFoster1
@KrisFoster1 3 жыл бұрын
Glad you enjoyed!
@Saje3l
@Saje3l 2 жыл бұрын
Totally Awesome!!!
@todaysrapsux123
@todaysrapsux123 3 жыл бұрын
thank you! subscribed!
@vin2629
@vin2629 2 жыл бұрын
Need a more advanced tutorial where the API calls are mocked
@FelipePereiradaSilva-q7f
@FelipePereiradaSilva-q7f Жыл бұрын
Thank you so much!
@paviyarasanv4192
@paviyarasanv4192 2 жыл бұрын
Can you please upload. how to test redux login page
@Steel0079
@Steel0079 3 жыл бұрын
Thanks for taking the time to make the video on the topic. I am running into a problem, near 17:07, where you place the below line of code in both tests. expect(todoElement).toContainHTML("") I get the error saying expect(element).toContainHTML() Expected: Received: Make dinner Can you please tell me why it isn't working for me?
@BumLowkey
@BumLowkey 3 жыл бұрын
try replace "" by "strike", I think different versions
@lekkyjayz6294
@lekkyjayz6294 3 жыл бұрын
Instead of: import renderer from 'react-test-renderer' use: import TestRenderer from 'react-test-renderer'
@willemkapenda2107
@willemkapenda2107 3 жыл бұрын
Thank you very much for this
@PierreLaBaguette
@PierreLaBaguette 3 жыл бұрын
why?
@jeanlaguna6949
@jeanlaguna6949 2 жыл бұрын
nice tutorial. Just one thing.... toContainHTML receive just the name of the tag without the ""
@TlbHibiki
@TlbHibiki Жыл бұрын
I was just going through this tutorial and I had this issue with toContainHTML not liking and should be changed to remove the .
@oleksandrhusiev6544
@oleksandrhusiev6544 3 жыл бұрын
Top, thanks!
@KrisFoster1
@KrisFoster1 3 жыл бұрын
Glad you enjoyed!
@bhaskardas3777
@bhaskardas3777 2 жыл бұрын
U are awesome.
@ManishKumar-mi7ko
@ManishKumar-mi7ko 3 жыл бұрын
thank you so much
@IncolasCopperfield
@IncolasCopperfield 3 жыл бұрын
thank you
@Daniel__g12
@Daniel__g12 6 ай бұрын
Get the lowdown on future developments in an exclusive interview with Binance's CEO
@ax3lgarcia675
@ax3lgarcia675 2 жыл бұрын
why sompeople speak about .babelrc or babel.config.js ? you don't speak about that
@coolpythoncodes5768
@coolpythoncodes5768 3 жыл бұрын
🚀🚀🚀
@juhandvan
@juhandvan 3 жыл бұрын
thanks
@KrisFoster1
@KrisFoster1 3 жыл бұрын
Glad you enjoyed!
@aprimic
@aprimic 3 жыл бұрын
you have the voice of Ross from friends, not the accent though
@KrisFoster1
@KrisFoster1 3 жыл бұрын
😂
@iliketocode6986
@iliketocode6986 3 жыл бұрын
So annoying how they change the api
@PierreLaBaguette
@PierreLaBaguette 3 жыл бұрын
my 2 cents - I believe that a to-do item would typically be an item in a list, therefore don't use DIV tag but LI (list item). it will also help your accessibility efforts and spread good practices and love :) edit: the same with the h1 element use - h1 is a main header of a page, Header level 1. pages should typically have only one element like that. why not use just P, Span or Strong instead? (check udacity course about Web Accessibility) + I'd love to see how you test state changes of elements, especially of parent and child element, each of them having co-related states
@jackstorm777
@jackstorm777 2 жыл бұрын
It's a course on unit testing, not HTML best practices :)
@PierreLaBaguette
@PierreLaBaguette 2 жыл бұрын
@@jackstorm777 (bad) habits have high chances of becoming the default way of doing things. one might forget the good practices if they don't get applied when possible
@jerodnilstead5985
@jerodnilstead5985 2 жыл бұрын
nice tutorial, back up from the mic a bit, hearing your mouth function is quite unpleasant.
@deathmetal0073
@deathmetal0073 2 жыл бұрын
Kewl
@NavyCuda
@NavyCuda 2 жыл бұрын
The lip smacking is just terrible. Why do people do that? I really want to watch your content but the lip smacking just drives me insane. It is so avoidable, it's like people don't take the time to listen to their audio before posting.
@Human_Evolution-
@Human_Evolution- 2 жыл бұрын
Not a fan of the const H1 stuff. Nope. And I hate tests. I think I hate every testing video on KZbin.
@anmolgupta1407
@anmolgupta1407 3 жыл бұрын
Hi, Can I have your email id? It was not mentioned inside the 'About' section of your channel.
@LS9690
@LS9690 Жыл бұрын
Nice explanation. Although expect(todoElement).not.toContainHTML(''); this test does not work.
@aaronmatto1375
@aaronmatto1375 2 жыл бұрын
Amazing video. Thank you!
@AhmadMaartmesrini
@AhmadMaartmesrini 11 ай бұрын
thank you
NodeJS & Express - Google OAuth2 using PassportJS
20:33
Kris Foster
Рет қаралды 111 М.
React Testing for Beginners: Start Here!
1:17:14
Programming with Mosh
Рет қаралды 146 М.
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
Testing In React Tutorial - Jest and React Testing Library
21:28
10 React Hooks Explained // Plus Build your own from Scratch
13:15
Fireship
Рет қаралды 1,4 МЛН
Next.js with React Testing Library, Jest, TypeScript
25:04
Dave Gray
Рет қаралды 75 М.
React Testing Library Crash Course
1:16:52
Laith Academy
Рет қаралды 89 М.
Stop Writing So Many Tests
10:02
Web Dev Simplified
Рет қаралды 99 М.
How to use Vitest with Jest-DOM and React Testing Library
12:19
EricWinkDev
Рет қаралды 41 М.
React Testing Tutorial with React Testing Library and Jest
41:43
Jest Crash Course - Learn How to Test your JavaScript Application
1:06:53