【问题标题】:Difference between jest.fn(implementationCallback) and jest.fn().mockImplementation(implementationCallback)jest.fn(implementationCallback) 和 jest.fn().mockImplementation(implementationCallback) 之间的区别
【发布时间】:2020-11-02 00:55:45
【问题描述】:

我注意到,当我们在 jest.fn() 中将实现作为参数传递给 .fn() 和 jest.fn().mockImplementation() 时,我们得到了相同的行为。如果是这样,选择合身只是品味问题?

例子:

jest.fn((num1, num2) => num1 + num2)
// same as 
jest.fn().mockImplementation((num1, num2) => num1 + num2)

有人有什么想法吗?

【问题讨论】:

    标签: reactjs jestjs babel-jest ts-jest


    【解决方案1】:

    jest.fn(implementation)jest.fn().mockImplementation(implementation) 的简写

    没什么好想的:)

    【讨论】:

    猜你喜欢
    • 2021-11-14
    • 2017-04-26
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 2021-12-20
    • 2017-12-24
    • 2020-06-09
    相关资源
    最近更新 更多