Testing SMART components and SERVICES with Signals and RxJS

preview_player
Показать описание

We've already looked at how to test "dumb" components, now we are going to look at how to test how those components are integrated into the application using smart components and services.

0:00 Introduction
0:51 State management recap
1:31 How do tests fit in?
2:40 Smart component: inputs
4:03 Smart component: outputs
4:52 Testing the service
6:11 Not always this easy

#angular #rxjs #testing

Рекомендации по теме
Комментарии
Автор

Great video! Have you tried Angular testing library? If yes, what do you think of their guiding principle of "The more your tests resemble the way your software is used, the more confidence they can give you." ?

BDF
Автор

thanks a lot for this video, testing is the most time consuming when working on a big project

wiliam
Автор

I'd love to see a video on how you actually went about using ChatGPT to help write the modal component mock

CraigGoldstone
Автор

Thanks for sharing your expertise with the community, although I think the test around the smart component need to be tweaked a bit. Generally speaking using a mocked function (e.g. jest.fn) is the way to go, but I think it in this case is an oversemplification that doesn't actually mimic the behaviour accurately. Signals are not just simple functions, and when you update a signal you would aspect the component to react to it, the latter doesn't happen when you model the signal as a simple function which reduce the confidence the code works properly. We can still stub the service but I'd use a signal that the test can control instead. What do you think?

marco.garofalo
Автор

@JoshuaMorony Great video. Question for you
​How would you go about in the scenario where you'd have let's say an effect in the smart component that triggers a method (let's assume a private method that calls a service like analytics tracking) every time the checklist changes. So you need to test that after checklist is being modified, you want to check if this service is being called. Would you perhaps mock the effect itself or maybe try using real signals?

XemiemiX