Maintainable Tests while maintaining Sanity | Niklaas Baudet von Gersdorff | EnterpriseNG 2021
Do you skip writing unit tests just because of NullInjectorErrors or missing component bindings?
Many inexperienced developers lack the knowledge to add new logic to existing components without creating bugs to established features. Masking their insecurity they’ll rely solely on their ability to “figure it out,” and skip vital steps in the process.
When creating new components, it’s not enough to cross your fingers and hope that the automagically created spec file will just keep working, because most of the time – it doesn’t. And when it fails, there is a greater chance of bugs being introduced into production.
You don’t want to put yourself in a scenario where you have a failing spec file, a manager breathing down your neck, and an impending product launch date.
In this talk, you’ll learn:
Why, how, and what to mock
Why you should avoid NO_ERRORS_SCHEMA
How to make the connection between `NgModule` and `TestBed` comprehensible
How to configure an Angular `TestBed` from the ground up, from zero to hero
How to lay the ground for fast and lean spec files
Additionally, I’ll be providing a step by step guide on how to configure a `TestBed` for a component with a lot of different dependencies (other components, pipes, services and modules) using `ng-mocks` and other utilities.
Upon completion of this session, you’ll have the tools and knowledge you need to confidently approach unknown codebases because configuring a `TestBed` and unit tests will be an enjoyable and fun process. You’ll have more time to focus on what is actually important: why and how to test specific behavior, rather than “how to get that spec file going again.”
ng-conf is a multi-day Angular conference focused on delivering the highest quality training in the Angular JavaScript framework. 1500+ developers from across the globe converge on Salt Lake City, UT every year to attend talks and workshops by the Angular team and community experts.
Join the Angular Community: http://www.ng-conf.org/
Get your ng-conf tickets: https://ti.to/ng-conf
Follow Us: https://twitter.com/ngconf
Learn More: https://ng-conf-school.teachable
Read More: https://medium.com/ngconf
Hear More: http://theangularshow.com
Official Website: https://www.ng-conf.org/