Testing reactivity: elapse method
- The simulated time can be controled by using the
session$elapse()
method.
testServer(server, {
expect_equal(rv$x, 0)
session$elapse(100) # Simulate the passing of 100ms
expect_equal(rv$x, 1) # The observer was invalidated and the value updated!
# You can even simulate multiple events in a single elapse
session$elapse(300)
expect_equal(rv$x, 4)
})
Using this approach, this test can complete in only a fraction of the 100ms that it simulates.
reactivePoll()
invalidateLater()
reactiveTimer()