Node.js 关于类型安全的模拟接口、函数和类

Node.js 关于类型安全的模拟接口、函数和类,node.js,typescript,testing,types,jestjs,Node.js,Typescript,Testing,Types,Jestjs,我正在尝试测试类型为的处理程序函数 为此,我需要模拟它的三个参数。但我不知道用笑话和打字脚本做这件事的最好方法是什么。我的测试文件是一个Typescript文件,所以类型安全性非常重要 // Arrange // This is my mock of the 1st argument of the handler function const mockedCreateJob = jest.fn<ZB.Job<any>,[]>(() => { return E

我正在尝试测试类型为的
处理程序
函数

为此,我需要模拟它的三个参数。但我不知道用笑话和打字脚本做这件事的最好方法是什么。我的测试文件是一个Typescript文件,所以类型安全性非常重要

// 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
//排列
//这是我对handler函数的第一个参数的模拟
const mockedCreateJob=jest.fn(()=>{
将预期的.JOB返回为ZB.JOB
})
//表演
//这是我对处理程序的调用
等待AvailableTestationsworker.handler(新建mockedCreateJob()、新建mockedCreateComplete()、新建mockedCreateWorker())
//断言
我得到这个错误:

 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.
类型“{elementInstanceKey:string;变量:{correlationKey:string;customerId:string;};customHeaders:{client_id:string;client_secret:string;env:string;};}”缺少类型“Job”中的以下属性:key、类型、workflowInstanceKey、bpmnProcessId等6个。

如何确保我将仅覆盖
ZB.JOB
界面的少数道具的对象(预期的.JOB)强制转换为“完整”对象?

请提供您要测试的代码。