Closed steineggerroland closed 1 year ago
Hi,
In our projects, all interactions with the Scheduler
are gathered in the same class. So for instance, we can have a class named ScheduledJobs
that will contain something like this:
scheduler.schedule(service1::someTask, schedule);
scheduler.schedule(service2::someTask, schedule);
scheduler.schedule(service2::someTask, schedule);
...
With this pattern:
What is your use case that requires to mock the Scheduler
dependency?
I am closing this issue because I do not have feedback.
Feel free to reopen if needed.
Hi,
I started using the scheduler and I like the API. But I am facing an issue when testing components using the scheduler. The Scheduler class itself is final, therefore, it cannot be mocked using e.g. mockito. How do you test a component having an Scheduler as dependency?
Using the real scheduler is hard, as it does not come with test-helpers. In contrast, when testing javascripts built-in scheduler there are a bunch of helpers. E.g., "Configure scheduler to not be time dependent", "Run all scheduled tasks now", "Run the task that is scheduled next" etc. See https://jestjs.io/docs/timer-mocks
Can I achieve this with Wisp?