如何为类实现接口编写笑话测试

问题描述 投票:0回答:0

1.ts

export interface abc { newMethod(x: string,y: string, z: Map<string, string>) }

2.ts `导出类 newClass 实现 abc {

newMethod (x: string,y: string, z: Map<string, string>){
    //code 

} }` 对于上面的代码,我想写个笑话测试用例

`describe('newMethod', () => {

// let inst: JsonResponseParser;
let outStream: PassThrough;
afterAll(() => {
    jest.resetAllMocks(); 
  }); 

test('newMethod', async () => {
    let result = newClass.newMethod(S,D,K) 
    
    expect(result).not.toBeUndefined();
});

});`

我试过这个但是在 newClass.newMethod(S,D,K) 出现错误“属性‘newMethod’在类型‘typeof newClass’上不存在”

javascript typescript unit-testing jestjs ts-jest
© www.soinside.com 2019 - 2024. All rights reserved.