Below is my code snippet
code
applyFilter(event: Event): void {
const filterValue = (event.target as HTMLInputElement).value;
this.filterBy = filterValue.trim().toLowerCase();
this.dataSource.filter = filterValue.trim().toLowerCase();
}
Test cases
fit('applyFilter', () => {
const event = new Event('click');
component.applyFilter(event);
});
Error i am getting is "TypeError: Cannot read property 'value' of null" while this conversion "(event.target as HTMLInputElement).value;" meentioned error is occuring