I am trying to update item, I wrote a function which gets the items from the store and update with new item based on user's selection with this.name and this.price but the same item.id that is intended for update.
public updateItemData(){
return this.store.select(itemSelector).subscribe(item => {
this.updatedItem = {
id: item.id,
name: this.name,
price: this.price
}
})
}
This works perfectly without any issue but in a unit test.
it('should create', () => {
expect(component).toBeTruthy();
});
It marked green but with displayed error.
TypeError: Cannot read properties of undefined (reading 'id')
When I ran the project, I didn't get any error concerning the "undefined property" or whatever. I started writing the test
Please help to resolve this. I will appreciate.