Clock
Move the device's wall clock forward, set it to an instant or freeze it, to test trials, expiries and schedules without waiting.
warden ui clock advance 10d expires a 14-day trial; reset brings real time back. The app reads Date.now().device.clock moves the wall clock the app reads with Date.now(), so a 14-day trial can expire in one step. The real time comes back when the test ends or the lease is released.
await device.clock.advance("15d");
await device.clock.set("2027-01-01T00:00:00Z", { frozen: true }); // iOS only
await device.clock.during("2027-01-01T00:00:00Z", async () => { /* ... */ });
await device.clock.reset();| Call | Does |
|---|---|
advance(duration) | move the clock forward from now |
set(instant, { frozen? }) | jump to an ISO instant; frozen holds it there (iOS only) |
during(instant, fn) | run fn at that instant, then restore |
reset() | back to the suite's conditions.clock, or real time without one |
Durations are milliseconds or "10s", "2m", "2d". The wall clock moves; monotonic clocks do not, so timers and animations keep running.
Per platform
- iOS: the clock changes for an app launched with the network dylib (the same rule as the network). A frozen clock holds the wall clock at one instant.
- Android: the emulator's clock changes. It cannot be frozen (
E_UNSUPPORTED).
Practice
- A large offset breaks TLS: certificates look expired or not yet valid, so HTTPS fails while the clock is far from real time. Do not make requests in a spec that advances the clock by weeks.
- A JS timer armed while the clock was ahead waits for the shifted time once the clock goes back. Re-read the time on demand (the example's clock card has a Refresh button) or relaunch the app after
reset().
In a suite
conditions: { clock: { offset: "2d" } },clock takes an ISO instant (it keeps running), { at, frozen? } or { offset: "2d" }. On iOS, declaring it launches every app with the dylib.
By hand
warden ui clock advance 15d
warden ui clock resetSee warden ui for every flag.
Limitations
- A frozen clock is iOS only.
- HTTPS fails while the clock is far from real time.