Skip to content

Testing Interactions (Click, Input)

Tests can simulate user interactions like clicking buttons or entering text.

it("should increment counter on click", () => {
const button = fixture.nativeElement.querySelector("button");
button.click();
fixture.detectChanges();
expect(component.count).toBe(1);
});
it("should update input value", () => {
const input = fixture.nativeElement.querySelector("input");
input.value = "Angular";
input.dispatchEvent(new Event("input"));
fixture.detectChanges();
expect(input.value).toBe("Angular");
});