Angular Unit Testing with Jasmine and Karma: A Practical Guide
How Angular unit testing fits together — TestBed, Jasmine, and Karma — plus code coverage, testing pipes, and testing attribute directives, with examples.
Angular features, testing with Jasmine/Karma, and migration guides.
10 articles
How Angular unit testing fits together — TestBed, Jasmine, and Karma — plus code coverage, testing pipes, and testing attribute directives, with examples.
Angular ships a schematic that rewrites *ngIf and *ngFor to the new @if and @for control flow automatically. The command, what it does (and doesn't) handle, and how to run it safely per-directory.
Angular's built-in control flow — @if, @for, @switch — replaces *ngIf and *ngFor. Correct syntax (including the mandatory track and the @empty block), why it needs no CommonModule, and the interview points.
Angular 17's headline changes: built-in @if/@for/@switch control flow, deferrable views with @defer, and the automatic migration schematic. A full guide.
Angular's @defer block lazy-loads part of a template on a trigger — viewport, interaction, idle, hover or timer — keeping non-critical content out of the initial bundle. Correct syntax, every trigger, prefetching, and the SEO caveat.
Build a custom AG Grid filter in Angular by implementing IFilterAngularComp — agInit, isFilterActive, doesFilterPass, getModel/setModel — and registering the component on the column. Correct, complete, runnable code.
How to unit test Angular pipes with Jasmine/Karma. Pure pipes need no TestBed — instantiate and assert on transform(). Plus testing pipes that inject dependencies, parameterised pipes, and pipes used inside a component template.
Test Angular attribute directives with a standalone host component, TestBed, By.directive, input changes, and assertions for default and bound behavior.
How to excludes mock files from ng test --code-coverage
Generate Angular code coverage with ng test --code-coverage, read the HTML report, enforce thresholds in karma.conf.js, and exclude files that shouldn't count.