首页 > 解决方案 > 开玩笑监视数组元素

问题描述

我将函数存储在一个数组中。在我的测试中,我需要监视该数组中的函数。这可能吗?

const myArray = [];
myArray.push(() => {
    console.log('first');
});
myArray.push(() => {
    console.log('second');
});

例如,我将如何监视上面代码中添加到数组中的两个函数?

标签: javascriptunit-testingjestjs

解决方案


推荐阅读