Mocking React Components and Functions using Jest for Beginners - React.js Testing Tutorial #5

Mocking React Components and Functions using Jest for Beginners - React.js Testing Tutorial #5

Bruno Antunes

2 года назад

54,750 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

A OlaUsoro
A OlaUsoro - 10.12.2021 01:35

Hi Brune, Really find this tutorials on testing helpful especially for a beginner into testing like me. Could you recommend another means of mocking react components as mocked - ts-jest/utils has been deprecated?😁

Ответить
Vittorio Morellini
Vittorio Morellini - 09.08.2023 22:59

This is an amazing series on test.
Simply wonderfull

Ответить
Moisés Briseño Estrello
Moisés Briseño Estrello - 25.06.2023 11:34

El mejor tutorial de pruebas que he visto en la red. Te agradezco muchísimo Bruno!!

Ответить
Sue lucero Martinez herrera
Sue lucero Martinez herrera - 23.06.2023 08:57

Hello, this is pretty clear and helpful, just one question , what happen if I m not using typescript, in minute 12 more or less you used mocked() that comes from ac ts library, I did not understand it a lot, if it is a normal js file how can I use it? :)

Ответить
Lix
Lix - 26.01.2023 23:02

Excellent explanation. Thanks!

Ответить
Sasha Shaikevich
Sasha Shaikevich - 17.12.2022 19:02

Really helpful as always Bruno. Thank you !

Ответить
Gabriel francelino
Gabriel francelino - 25.11.2022 04:31

Excellent explanation, you gained another subscriber, congratulations!

Ответить
Faris Rayhan
Faris Rayhan - 11.11.2022 12:48

Thanks awesome tutorial

Ответить
Mateus Torquato
Mateus Torquato - 01.10.2022 00:51

Hey man, nice video, thanks a lot for it. I'd like to know if you know how to deal with a situation that I have the component displayed twice or more inside a component, and I want to validate the params sent to both? Like:

<>
<MyComponent param={1} />
<MyComponent param={2} foo="bar" />
</>


How would I test those two components separately if when I mock it, I mock both at the same time?

I appreciate man =) The way you explain is simple and didactic, loved it.

Ответить
SilverLion30
SilverLion30 - 21.08.2022 15:05

So awesome materiallll broooo

Ответить
Ghostpieces
Ghostpieces - 18.08.2022 08:50

Loved it, Thank you :)

Ответить
Luca Di Fazio
Luca Di Fazio - 15.07.2022 01:19

Finally, I've understood what spying and mocking is! Thanks!!!!

Ответить
Beginner Programmer
Beginner Programmer - 10.06.2022 11:35

This guy is something else...

Ответить
Kristoffer Rasmussen
Kristoffer Rasmussen - 06.06.2022 00:09

This is by far the best tutorial on mock/spy that i have found. Thanks

Ответить
Alberto P. Neto
Alberto P. Neto - 19.05.2022 01:41

Great video!
But I have a problem. What do I use instead of the "mocked" function, given I'm not using Typescript and therefore am not using "ts-jest/utils"? Thanks

Ответить
Gfast Gao
Gfast Gao - 18.05.2022 19:30

Super professional tutorial I've seen so far. Really many practical tricks explained here which our team spent years to figured out with Jest.
Still looking for a trick to save memory when jest is running.

Ответить
Reza Safari
Reza Safari - 13.05.2022 23:25

Love your presentation man. awesome !!!

Ответить
deadlock
deadlock - 12.04.2022 21:58

This is very informative! Thank You!

Ответить
SemyonZgurskiy
SemyonZgurskiy - 14.03.2022 09:50

Thank you so much! Your manner of explanation is great!

Ответить
Danny Roberts
Danny Roberts - 13.03.2022 12:20

Thank the lord for this guy 👏I'm a junior dev' and I started working for a big company three months ago. I had no experience of testing and it has severely affected my performance in this role, I wish I had have seen this video two months ago but it's still useful for me. Lots of other jest videos out there are good, but pretty basic, this one is up to date and exactly how my company mocks so cheers Bruno.

P.s. I know it sounds like I'm this dude's friend giving him a nice review, but I don't care this video is deffo worth it for anyone who doesn't have a goosy about testing like myself a short while ago.

Ответить
Danny Roberts
Danny Roberts - 13.03.2022 12:14

Thanks

Ответить
ArVentures
ArVentures - 01.03.2022 13:45

Thanks bro!

Ответить
G G
G G - 12.02.2022 22:54

Very helpful, esp the last trick. Thank you.

Ответить
Thaung Than Han
Thaung Than Han - 12.02.2022 07:22

Thank you for this great instruction. By the way,
Does the same concept apply to the react native applications?

Ответить
HandyMandy
HandyMandy - 07.02.2022 17:19

What a great video. Thanks for putting this together. Nice and clear

Ответить
Brainwaves Potential
Brainwaves Potential - 04.02.2022 23:56

Hi Bruno, thank you for posting this for us! I really like your tutorials.

May I ask one question:

Why do you use "mocked" from "ts-utils" for mocking the DataGrid, but it was not necessary for mocking the VeryComplex component? When do I know if I need to use the "mocked" from ts-utils?

Thanks!

Ответить
Attamjot Singh
Attamjot Singh - 09.01.2022 19:12

Hey Bruno, awesome video, you mocked the Dataggrid with mocked function from ts-grid, but I am not using typescript in my project. How to mock it then and also what is the significance of mocking here with ts-grid when you are mocking it with jest.mock ??

Ответить
Praveen Kumar
Praveen Kumar - 15.12.2021 18:09

You gave my motivation back brother... Thank you so much :) So happy that i found your channel :)

Ответить
Andriy Vozniuk
Andriy Vozniuk - 24.11.2021 15:08

Hello Bruno! Your video is so helpful, thx! I have one question.

Can I mock my own component or component from any library only in specific tests?
Cause now I unfortunately didn’t find a correct way and my solution is to create two test files with mock and without, so, it is no a better solution 😄

Ответить
rickvian
rickvian - 12.11.2021 16:28

Chances you will bump to this problem:
TypeError: Cannot read property ‘generatedLine’ of undefined

if you are on react-script v4 and jest 26 , you have to do

jest.spyOn(global.Math, "random").mockReturnValue(0.42);

Ответить
Elmahfoud Majidi
Elmahfoud Majidi - 31.10.2021 21:54

Liking this before watching. Been a while since I have found one of your videos.

Ответить
Paul Pardee
Paul Pardee - 28.10.2021 20:27

Oh my gosh, I spent all day yesterday looking at articles on how to do this and got nowhere. 6 minutes into your video and I have a passing test! Thanks!

Ответить
Cristian Rodríguez
Cristian Rodríguez - 22.09.2021 20:10

Thanks!

Ответить
Guerilla Jones
Guerilla Jones - 06.09.2021 16:40

This is the best testing video I've ever seen!

Ответить
Kevin
Kevin - 25.08.2021 00:14

Thanks!

Ответить
maks tarr
maks tarr - 19.08.2021 16:57

Thank you Bruno for this wonderful series! 🤓👍👍👍

Ответить
N. S.
N. S. - 18.08.2021 10:46

Very useful tips! Thanks! :)

Ответить
0xPanda
0xPanda - 09.08.2021 22:32

You videos are so great ☺️

Ответить
Ricardo Costa
Ricardo Costa - 09.08.2021 14:53

Second first comment 😋

Ответить
Mahmoud
Mahmoud - 09.08.2021 13:56

first comment 😂😍

Ответить