Maintainable Tests while maintaining Sanity
December 2nd, 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.”