Worker automated testing - KV Store operations

I wrote a worker framework with reusable components, using TypeScript. As part of the framework, I implemented a comprehensive set of tests, which rely on packages like service-worker-mock and @cloudflare/workers-types. The testing is the part that I need to complete, to get full coverage.

Apart from some minor discrepancies between the service mock and the live environment (e.g. the cache mock stores content with any key, even if it’s not a fully qualified URL, whereas the actual cache throws an error), everything works quite well. However, I wasn’t able to find a mock for CloudFlare’s KV Store. Technically, that looks like a simple read/write class, with methods like set/put, get and delete and, in theory, I could also write a mock KV Store from scratch for that purpose. However, since I would like to test all the features of the KV Store, such as content expiration and so on, I would rather use an existing mock, if there is one.

Bottom line: does a KV Store mock library, component, exist “in the wild”?

Once again, thanks for the help.

1 Like