jest.fn(implementationCallback) 和 jest.fn().mockImplementation(implementationCallback) 的区别 [英] Difference between jest.fn(implementationCallback) and jest.fn().mockImplementation(implementationCallback)

查看:43
本文介绍了jest.fn(implementationCallback) 和 jest.fn().mockImplementation(implementationCallback) 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've noticed we got the same behavior when we jest.fn() with the implementation passed as param in the .fn() and jest.fn().mockImplementation(). If so, choosing the fit is jut a matter of tastes?

示例:

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

有人有什么想法吗?

推荐答案

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

没什么好考虑的:)

这篇关于jest.fn(implementationCallback) 和 jest.fn().mockImplementation(implementationCallback) 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆