0Pricing
Angular Academy · Lesson

Testing Inputs, Outputs, and DOM

Assert on rendered output and events.

Testing the Component Contract

Components communicate through inputs (data in), outputs (events out), and the rendered DOM. Good component tests drive these three surfaces and verify the visible result, not internal implementation details.

Setting an Input

Assign to the component instance's input property, then call detectChanges() to re-render. With signal inputs you set via fixture.componentRef.setInput().

fixture.componentInstance.label = 'Save';
fixture.detectChanges();
// signal inputs:
fixture.componentRef.setInput('label', 'Save');
fixture.detectChanges();

All lessons in this course

  1. TestBed and Component Fixtures
  2. Testing Inputs, Outputs, and DOM
  3. Mocking Services and Dependencies
  4. Testing Signals and Async Code
← Back to Angular Academy