相关疑难解决方法(0)

用玩笑测试打字稿中的私有函数

在下面的代码中,我的测试用例按预期通过,但我使用 stryker 进行突变测试,handleError 函数在突变测试中幸存下来,所以我想通过测试是否调用 handleError 函数来杀死突变体。需要帮忙测试私有函数。

我试过 spyOn 但没有用

const orderBuilderSpy = jest.spyOn(orderBuilder, 'build')
const handleError = jest.fn()
expect(rderBuilderSpy).toHaveBeenCalledWith(handleError)
Run Code Online (Sandbox Code Playgroud)

const orderBuilderSpy = jest.spyOn(orderBuilder, 'build')
const handleError = jest.fn()
expect(rderBuilderSpy).toHaveBeenCalledWith(handleError)
Run Code Online (Sandbox Code Playgroud)

typescript jestjs nestjs

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

jestjs ×1

nestjs ×1

typescript ×1