cloudflare / cloudflare/workers-sdk

Vitest fake timers don't affect storage simulators

Open
#5,394 1 comment 4 reactions 0 assignees View on GitHub
package:vitest
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
186

Description

Vitest's [fake timers](https://vitest.dev/guide/mocking.html#timers) do not apply to KV, R2 and cache simulators. They also don't apply to Durable Object alarms. For example, you cannot expire a KV key by advancing fake time. Ideally, this would work.

Miniflare has an existing fake timer system for its own tests: https://github.com/cloudflare/workers-sdk/blob/426906a96b378823295067fc9ca8a495712ae94e/packages/miniflare/src/workers/shared/timers.worker.ts It should be possible to hook Vitest's fake timers system into this, though it might be tricky to do this synchronously across a service boundary... 🤔

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.