Тёмный

How do I test and mock Standalone Components 

Rainer Hahnekamp
Подписаться 5 тыс.
Просмотров 2,9 тыс.
50% 1

Опубликовано:

 

1 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 35   
@rororlo
@rororlo Месяц назад
I've been fighting against this problem for hours, thanks for the video, all really clear!
@RainerHahnekamp
@RainerHahnekamp Месяц назад
Thanks, great to hear.
@Nabulio85
@Nabulio85 20 дней назад
Thank you. Great content 🙏
@pazzuto
@pazzuto 3 месяца назад
This is great content as always. The concern I have about moving to standalone components is the bundle size. I haven't taken a deep look into this, but I've read here and there that there's a lot of code duplicated and your app actually grows in size. I'm sure it can be mitigated with lazy loading, but it's something to consider.
@RainerHahnekamp
@RainerHahnekamp 3 месяца назад
Hi, where did you hear about the bundle size issue? Could it be that you are mistake standalone with the barrel files? Having a lot of barrel files (index.ts) will problems to your bundler because it might not be able to tree-shake them efficientyl, and you may end up with a huge initial bundle. Regarding Standalone vs NgModule, there is no impact on the bundle size.
@harshranjan8784
@harshranjan8784 6 месяцев назад
Great tutorial! Was able to finally understand how to inject mocks for standalone stuff. Thanks 😁
@RainerHahnekamp
@RainerHahnekamp 6 месяцев назад
Great to hear, you're welcome
@dimasavenkov2951
@dimasavenkov2951 6 месяцев назад
How about non-standalone dependencies? I have in my imports array some modules with related dependencies. I want to replace them with stubs which I already have. Should I create test module and include all stubs components in it and add it to the standalone imports?
@RainerHahnekamp
@RainerHahnekamp 6 месяцев назад
So you will always have to configure the TestingModule. There is no other way if you want to test via the DOM (and it is also the official recommendation). Without standalone, mocking is easier. you just declare your stubs instead the original ones. Declare, not import.
@dylanjhalltech8313
@dylanjhalltech8313 6 месяцев назад
I really enjoyed this video because you took a problem, demonstrated why it happens, demonstrated a solutions with explanation - then provided information on a third party product. With this video I learned so much, even beyond testing
@RainerHahnekamp
@RainerHahnekamp 6 месяцев назад
Thanks a lot Dylan!
@NicolasMaas
@NicolasMaas 5 месяцев назад
You mention the usage of ng-mocks library to Mock Standalone Components. We use this as wel to mock our services that we provide. However, sometimes, it uses the actual service instead of the mocked one. How do you properly mock these services that you provide?
@RainerHahnekamp
@RainerHahnekamp 5 месяцев назад
Hi, could it be the case that those services are provided by the component? Otherwise, it has to work as expected. Can you maybe provide an example?
@NicolasMaas
@NicolasMaas 5 месяцев назад
@@RainerHahnekamp The services are indeed all provided on the component itself.
@danywalls
@danywalls 4 месяца назад
Amazing content as always!!!!!
@RainerHahnekamp
@RainerHahnekamp 4 месяца назад
Thanks Dany and best wishes!
@yaibanoutsukushii
@yaibanoutsukushii 6 месяцев назад
another great explanation! thank you! it's embarassing but in my company we got new schematics using overrideCopmonents and I just did not bother finding out why... sometimes the test did not work and then I spend hours trying out different things. So happy I now understand, what it does!
@RainerHahnekamp
@RainerHahnekamp 6 месяцев назад
Yeah, so TestBed.override... is something we don't see that often but it is quite powerful
@besara_
@besara_ 6 месяцев назад
how to test Angular Guards ?
@RainerHahnekamp
@RainerHahnekamp 6 месяцев назад
Do you want to test only the guards or the guard in combination with a Component? In the first case, check out this video ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-mMiSmStwGOU.html, in the second that one: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-DsOxW9TKroo.html
@besara_
@besara_ 6 месяцев назад
@@RainerHahnekamp really, appreciated 👏
@MichaelSmallDev
@MichaelSmallDev 7 месяцев назад
I just ran into a situation like this today but with component store in a child component being the troublesome thing. I think this solution will work a lot better than what I tried to do. Thanks.
@RainerHahnekamp
@RainerHahnekamp 6 месяцев назад
You're welcome Michael! Happy to help.
@paevents8064
@paevents8064 7 месяцев назад
Awesome, great explanation. This is what I was looking for
@RainerHahnekamp
@RainerHahnekamp 6 месяцев назад
👍
@VinitNeogi
@VinitNeogi 7 месяцев назад
Indepth Info as always, thanks Rainer
@RainerHahnekamp
@RainerHahnekamp 7 месяцев назад
Thanks as well Vinit.
@rudyxxdevxx7323
@rudyxxdevxx7323 6 месяцев назад
Thanks Rainer, awesome video !
@RainerHahnekamp
@RainerHahnekamp 6 месяцев назад
You are very welcome Rudy
@dmytroukrainskiy
@dmytroukrainskiy 7 месяцев назад
Thanks for video)
@RainerHahnekamp
@RainerHahnekamp 7 месяцев назад
You're very welcome!
@rolandjost3823
@rolandjost3823 7 месяцев назад
Very good thanks...
@RainerHahnekamp
@RainerHahnekamp 7 месяцев назад
Thanks Roland.
@paulh6933
@paulh6933 7 месяцев назад
Cool!!!
@RainerHahnekamp
@RainerHahnekamp 7 месяцев назад
Thanks Paul!
Далее
How do test code using inject()
15:41
Просмотров 1,4 тыс.
Как открыть багажник?
00:36
Просмотров 14 тыс.
ХОККЕЙНАЯ КЛЮШКА ИЗ БУДУЩЕГО?
00:29
Don't Mock 3rd Party Code
19:56
Просмотров 39 тыс.
NgRx Signal Store: The Release
46:35
Просмотров 6 тыс.
Angular's Change Detection
27:31
Просмотров 7 тыс.
How do I test Signals (signal / computed / effect)
20:15
NgRx Best Practices - Episode 4: Facade Pattern
36:20
Просмотров 4,7 тыс.
Can You Make YouTube From Scratch Using Only Bash?
17:51
JavaScript Visualized - Closures
11:34
Просмотров 42 тыс.
Reactive Contexts
12:10
Просмотров 2,8 тыс.
Google Engineer Embarrassed Me In Chess
34:41
Просмотров 275 тыс.
Как открыть багажник?
00:36
Просмотров 14 тыс.