Choose the control from the decision
Trace the check that produces the result you care about. A timestamp in an API response is data; your app may still make the expiry decision using its own time source.
- Does the API report whether a resource is expired?
- Prepare that API case. Use supported API-time controls when its state must evolve; assert the response and your client’s handling.
- Does your code compare a timestamp with its own current time?
- Inject the time source or fake the app’s Date reads. Test the exact boundary in that code.
- Are you waiting for backoff, polling or a refresh callback?
- Control the application scheduler and its deadline source. Observe which callbacks and requests actually run.
- Does a database, worker or external service decide the time?
- Control that component separately. A clock double in the client process will not reach it.
Copy this into the test plan
CLOCK-CONTROL WORKSHEET
The decision I need to test: ______________________________
The component that makes that decision: ___________________
Its time source / scheduler: ______________________________
The input that defines expiry or the wait: ________________
The control I will move: __________________________________
What must remain unchanged: _______________________________
Expected before / at / after the boundary: ________________
State and pending work to clear before repeating: _________Apply the distinction to an expiring resource
The expiring-resource test contains the complete authored before, at and after expiry plan. It uses a disposable resource with a 60-second API lifetime while holding the app’s separate 30-second refresh callback pending, then checks what changes when the scheduler moves.
Keep both reset boundaries in the plan. Restoring the API episode does not clear the app’s cached resource ID, pending timers or observable state. Create again and use the returned ID when repeating.
Change the expiry owner, change the test. If your app instead compares a timestamp or a JWT expiry claim with its own current time, keep the API response fixed and move the app’s time source. The episode-resource contract does not validate arbitrary bearer tokens or apply a provider’s authentication policy.
When an ordinary test clock is enough
For an app-local timestamp check, pass a time source into the code or use your existing test runner’s mocked Date. For a scheduled wait, use its timer controls and observe callbacks. A fixed HTTP response is often enough for either test.
Changing mocked system time and running scheduled work are different operations. In Vitest, setting system time does not fire timers. In Node MockTimers, setting time does not execute timers, while ticking runs due mocked timers and can advance mocked Date too. Select the APIs your case needs.
Restore the real APIs and clear pending work after each test. For a worker, database or provider outside that process, use a control supported by that component or a separate integration case.
Retries add an attempt limit and total deadline. Keep those under the client’s scheduler and elapsed-time source; an API-time advance does not make the next attempt eligible. The retry-testing guide supplies assertions for those bounds.
Use API-time controls when the dependency owns the change
Time Chamber advances an episode’s simulated API time explicitly. Its supported resource lifetime changes what a resource read returns; it does not speed up app timers, change the host clock or interpret arbitrary token contents.
Check the documented create/read and lifetime contract before choosing it for your case. If that fits, the quickstart is the supported setup path.
For an inspectable clock boundary, the rate-limit walkthrough uses saved synthetic runs observed on October 18, 2026. Its player shows a recorded API-time advance followed by a separate client retry. That evidence concerns its saved scenario; the linked resource-expiry exercise is an authored test plan.