【问题标题】:Testing Reflux stores with Jasmine使用 Jasmine 测试 Reflux 商店
【发布时间】:2015-06-27 18:53:17
【问题描述】:

我正在尝试弄清楚如何使用 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 商店吗?

【问题讨论】:

    标签: jasmine reactjs refluxjs


    【解决方案1】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2015-05-11
      • 1970-01-01
      • 2015-02-14
      • 2020-06-18
      • 1970-01-01
      • 1970-01-01
      • 2015-07-24
      • 2015-04-12
      • 1970-01-01
      相关资源
      最近更新 更多