2

I'm trying to figure out how to test Reflux stores (https://github.com/spoike/refluxjs) using Jasmine. Basically, the equivalent of this question, except for the fact that there is no equivalent to runAllTimes that I know of: 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();
});

^ this fails, when it should return true.

So: anyone know how to test Reflux stores using Jasmine?

Community
  • 1
  • 1
Bonnie
  • 185
  • 9

1 Answers1

1

I solved this by manually ticking the Jasmine clock.

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

(With calls to jasmine.clock().install() and jasmine.clock().uninstall() in the setup and teardown, respectively.)

This feels like a hack. Anyone have a better way?

Bonnie
  • 185
  • 9