>

CODEMASTERYLAB

IDE PLATFORM
CoursesCommunity BlogsKnowledge GraphQuizzesInterview Prep

Sign in to track progress & earn XP

Sign In Create Account
>
Code Mastery Lab

Code Mastery Lab

Sign In

Testing Forms — Simulating Input, Validations, and Submissions

Question 1 / 1

0:00
Core
Medium

A test fills in an email input using dispatchEvent(new Event('input')) with value 'test@test.com'. The template shows an error with *ngIf="emailControl.invalid || !emailControl.touched". The test then asserts the error is hidden. The assertion fails — the error is still visible. What is the most likely cause?

typescript it('hides error when valid email is entered', () => { const input = fixture.nativeElement.querySelector('#email'); input.value = 'test@test.com'; input.dispatchEvent(new Event('input')); // sets value and dirty fixture.detectChanges();

const error = fixture.nativeElement.querySelector('.email-error'); expect(error).toBeNull(); // fails });