Predict Spy Call 实参
预测输出 中等
题目
什么是 值的 firstCallArgs?
代码
const spy = jest.spyOn(Math, 'max');
Math.max(3, 7);
const firstCallArgs = spy.mock.calls[0];
提示
首先 call 通过 3 and 7.
解释
firstCallArgs 是 [3, 7]. jest.spyOn(Math, '最大值') wraps Math.最大值 and 记录所有 calls. 首先 call Math.最大值(3, 7) 是存储 in spy.mock.calls[0] as 数组 [3, 7]. 你能 use 这个到 验证什么实参函数是 called 使用.
相关资源
相关课程
- Stubs and Spies
理解测试 doubles.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。