我有一个来自dynamoose的可链接方法,在测试中,我想向该链添加一个附加方法。
基本上,在测试中,我想替换所有的
实例Model.query(key).otherChainableMethods()
使用
Model.query(key).limit(LIMIT).otherChainableMethods()
所以我尝试了:
Model.query = jest.fn(key => Model.query(key).limit(LIMIT))
但这显然导致某种无限循环,因为我得到了RangeError: Maximum call stack size exceeded
如何在模拟实现中使用函数的原始实现?