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?😁
That's awesome to know my friend 😍 Yes, absolutely, It was deprecated 12 days ago =D Basically ts-jest/utils is now deprecated because it was moved (copy pasted) from ts-jest to jest itself (which is great news if you ask me) You'll be able to do ``` jest.mocked(SomeComponent) ``` and it works exactly as before, because it's the exact same code :) Just keep in mind that there was a mistake in that Pull Request and they forgot to export the mocked function. They have now a new PR opened, but not merged yet: PR: github.com/facebook/jest/pull/12133 Issue: github.com/facebook/jest/issues/12131 If you give them a few more days, then you can move from ts-jest/utils to jest itself :)
@@aolausoro2942 yeah, I will be doing a "find and replace" kind of job when they merge that one 😅😅😅 For now, nothing to worry about 😉😉 just subscribe to that GitHub issue/PR and when it gets merged it's party time 😂😂😂
@@BrunoAntunesPT Thank you for the awesome tutorial! I have learnt a lot from this single video and I can contribute directly to my project. However, jest.mocked() still does not work jest.mock('material-table', () => ({ ...jest.requireActual('material-table'), MaterialTable: jest.fn(() => Table), })); const mockedMaterialTable = jest.mocked(MaterialTable); ● Test suite failed to run TypeError: jest.mocked is not a function 35 | })); 36 | > 37 | const mockedMaterialTable = jest.mocked(MaterialTable); | ^ This is the error I am getting. Can you please help me with this?
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.
Hi Bruno, there are lots of testing tutorials on youtube but your tutorials are one of the best. Thank you for your great explanations. You took a break from youtube videos, I think you should continue. We're waiting for your new videos.
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.
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!
I'm sorry to hear that you spent a day looking for this information. On a positive note, I'm very happy you found value in my video 😍😍😍 thank you very much ❤️
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? :)
That was good! Will we have a video about mocking HTTP calls from the component. Or basically, this is the same as mocking async func calls that you described in the previous videos
Thank you very much my friend 😍 That will be Monday's video (video 6) 😊 we will be using msw (mock service worker) to help us mocking the http calls, then as you said, we will use also the concepts learned in Video 4 (async testing) 😊
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: 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.
Can i use jest.spy on in different js which is not my test file file or we have to use it in only test.js file and inside describe and test block only.
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 ??
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!
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
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 😄
Thank you very much 😍 When you do jest.mock you are mocking that dependency for all the tests in that file. I honestly never found a use case where inside the same file I want to have mocks for some tests and no mocks for other tests - but it's very possible that I'm understanding your request in a wrong way 😅