2

我试图弄清楚如何使用 Jasmine测试 Reflux 商店( https://github.com/spoike/refluxjs )。runAllTimes基本上,这个问题的等价物,除了我所知道的没有等价物: How to test Reflux actions with Jest

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 测试 Reflux 商店吗?

4

1 回答 1

1

我通过手动勾选 Jasmine 时钟解决了这个问题。

jasmine.clock().tick(jasmine.DEFAULT_TIMEOUT_INTERVAL);

(分别在设置和拆卸中调用jasmine.clock().install()和调用。)jasmine.clock().uninstall()

这感觉就像一个黑客。有人有更好的方法吗?

于 2015-04-20T21:48:32.220 回答