我正在尝试运行Jest测试的类。该类(不是测试)使用内部间隔。我正在尝试使用我在测试中创建的某些方法来测试它,如下所示:
create view vw as select
a,b,iif(c = 1,null,c) as c,coalesce(d,a) as d
from tbl
但是,似乎没有执行与类本身的间隔。我放了一些console.logs,发现它确实到达了设置间隔的代码点:
const syncWait = ms =>
{
const end = Date.now() + ms;
while (Date.now() < end) continue;
};
let myobj = new MyClass(); //the constructor starts the interval
syncWait(5500);
expect(...
但是,即使间隔时间过去了,它也根本不会执行。为什么会这样?