# Testing a Component — Angular

Source: https://www.geekswithgeeks.com/en/angular/ng-testing-basics

> TestBed sets up an isolated environment to test a component.

## What TestBed does

`TestBed` creates a mini Angular module for the test, letting you instantiate a component with real or fake dependencies and inspect its rendered output.

## A minimal test

This test creates the component, triggers change detection, and checks a value on the instance.

```typescript
describe('CounterComponent', () => {
  it('increments the count', () => {
    const fixture = TestBed.createComponent(CounterComponent);
    const component = fixture.componentInstance;

    component.increment();
    fixture.detectChanges();

    expect(component.count()).toBe(1);
  });
});
```
