我有一个来自 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
如何在模拟实现中使用函数的原始实现?