'Jest testing components and undefined values inside .toHaveBeenCalledWith
Jest testing components and undefined values inside .toHaveBeenCalledWith
Having issues testing that a value exists in cases where the value is a component or undefined (toolbarComponent). Is there a way to test these values without using jest-extended? I saw that expect.anything() doesnt work for an undefined value, but I dont know why expect.anything() doesnt work for a component.
expect(worklistMock).toHaveBeenCalledWith(
expect.objectContaining({
overflowColumns: expect.arrayContaining([
expect.objectContaining({ columnKey: 'order-category' }),
expect.objectContaining({ columnKey: 'order-date' }),
expect.objectContaining({ columnKey: 'order-due-date' }),
expect.objectContaining({ columnKey: 'ordering-location' }),
expect.objectContaining({ columnKey: 'ordering-provider' }),
]),
pinnedColumns: expect.arrayContaining([
expect.objectContaining({ columnKey: 'demog-patient-information' }),
expect.objectContaining({ columnKey: 'outstanding-order' }),
]),
worklistId: 'OrderTrackingWorklist',
toolbarComponent: expect.anything(),
placeHolderComponent: expect.anything(),
}),
expect.anything(),
);
toolbarComponent in the Error:
Expected: "toolbarComponent": Anything
Received "toolbarComponent": <OrderTrackingWorklistToolbar deleteWorklist={[Function deleteWorklist]} disabled={true} saveWorklist={[Function saveWorklist]} savedWorklists={{"lastUpdated": "", "selectedWorklist": "", "worklists": []}} selectWorklist={[Function selectWorklist]} />,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
