Goutm
Goutm

Reputation: 33

How to resolve ngrx store dispatch issue in unit test in angular 18

NGRX Store dispatch issue is not working in my code. Getting below error. So, How to resolve this issue.

TypeError: Cannot read properties of undefined (reading 'dispatch')

app.component.spect.ts:

it('should dispatch action and handle success response', () => {

 const actionInfo: INgrxActionInfo = 
 vasActionInfo[VasActionEnum.DELETE_DATA] as INgrxActionInfo;
 const payload = {
 inputData: {
    name: data.name,
    place: data.place,
 },
 };
 
 const dispatchSpyon = spyOn(store, 'dispatch').and.callThrough();
 expect(dispatchSpyon).toHaveBeenCalledWith(vasNgrxAction.action(actionInfo, true, payload));


});

Upvotes: 0

Views: 16

Answers (0)

Related Questions