Advice or examples for writing / running automated / local tests with KV Store interaction?

Hello! I’m working on a fairly small / simple Rust project that looks up some values from a KV Store item, does some JSON transformation, and returns a synthetic response (no origin / backend interaction).

I would love to write a handful of tests for this functionality.

I’ve searched around and have found a few resources that are useful, but not super up-to-date and also fairly simplistic. The most obvious resource is Fastly’s own post about this here: How to write Rust unit tests for your Compute application | Fastly - this is a good starting point, but is a bit old at this point (for me at least it doesn’t “just work”) and doesn’t cover stubbing services.

There is a also a community post here, but didn’t seem like any interaction there:

I’m aware the Rust community itself / documentation / examples, unrelated to Fastly, likely can help me figure out how to mock / stub in an external service (assuming this is possible in Rust to begin with), but the WASM angle / addition adds another step. Before I go down that path I figured I’d ask here if there might be any up-to-date Fastly examples of more complex testing with mocks and such?

Thanks for any advice!

Our local testing tool for Compute (Viceroy) has the ability to emulate KV Stores (and Config/Secret Stores): fastly.toml package manifest format | Fastly Documentation

This is how we generally test our own Compute applications.

We also have a testing framework which uses tests written in JavaScript to ‘drive’ an application in Viceroy: GitHub - fastly/js-compute-testing: Write JavaScript tests from Node.js, against a local or remote Fastly Compute application