我想为Function prototype创建一个自动添加setTimeout的方法。我用这个买到的:Function.prototype.defer = function (delay) {};function现在,我需要将参数传递给我的函数,如下所示: console.log( a + b );我只是通过跑而不是用setTimeoutdelay) {
在运行jest测试时,我得到了一个错误Jest did not exit one second after the test run has completed,因为这个setTimeout这个问题迫使我思考,我应该如何处理这个setTimeout,以便在服务器停止或开玩笑测试结束时立即运行它在这种情况下,处理计时器的正确方法是什么?