I'm trying to test my handler
function whose type is https://github.com/zeebe-io/zeebe-client-node-js/blob/master/src/lib/interfaces.ts#L243
To do this, I need to mock its three arguments. But I don't know what is the best way to do it using Jest and Typescript. My test file is a Typescript file so type safety is very crucial.
// Arrange
// This is my mock of the 1st argument of the handler function
const mockedCreateJob = jest.fn<ZB.Job<any>,[]>(() => {
return EXPECTED.JOB as ZB.Job<any>
})
//Act
// This is my call of the handler
await availableAttestationsWorker.handler(new mockedCreateJob(), new mockedCreateComplete(), new mockedCreateWorker())
// Assert
I get this error:
Type '{ elementInstanceKey: string; variables: { correlationKey: string; customerId: string; }; customHeaders: { client_id: string; client_secret: string; env: string; }; }' is missing the following properties from type 'Job<any, KeyedObject>': key, type, workflowInstanceKey, bpmnProcessId, and 6 more.
How do I make sure I cast my object (EXPECTED.JOB) that overrides only a few props of the ZB.JOB
interface to a "full" object?
Aucun commentaire:
Enregistrer un commentaire