我正在尝试弄清楚如何使用Jasmine测试Reflux存储(https://github.com/spoike/refluxjs)。基本上,相当于这个问题,除了没有等价于我所知道的runAllTimes
:如何用笑话测试反流动作
it('responds to the doTheThing action and triggers afterward', function() {
var spyFn = jasmine.createSpy('spy');
MyStore.listen(spyFn);
MyActions.doTheThing();
// with Jest, I would call jest.runAllTimers() here
expect(spyFn).toHaveBeenCalled();
});
^ 当它应该返回 true 时,这将失败。
所以:有人知道如何使用茉莉花测试回流商店吗?
我通过手动滴答茉莉花时钟解决了这个问题。
jasmine.clock().tick(jasmine.DEFAULT_TIMEOUT_INTERVAL);
(分别在设置和拆卸中调用jasmine.clock().install()
和jasmine.clock().uninstall()
。
这感觉就像一个黑客。有人有更好的方法吗?