/technology/modules/ · testing Shipping
testing
The conformance kit every module runs against. Fake ports, an in-memory database, and no network.
What it is
testing.
TestHarness::new takes your modules, fakes every port, applies each module's SQLite migrations to a fresh in-memory database, and assembles the router. It hands back the router and every fake — mailer, captcha, rate limiter, database, clock, KV, HTTP, defer, signer, events, modules, dialect — so a test asserts on what the module did rather than on what it returned.
No network, and no cloud. The default kit is an in-memory SQLite database and fakes, which is what makes the suite the same on a laptop, in CI and inside a Worker build, and why a module can be tested at all before it has anywhere to run. The Postgres feature runs the same tests against a real server, so a module is checked on both dialects in CI. conformance(Box::new(MyModule::new())) is one line and runs the shared rules every module must pass.
Crate
cratefield-testing · 0.1.1, MIT
Ports
test harness — it fakes all of them
A 15-line module test
conformance(Box::new(MyModule::new())) for the shared rules, then request(&kit.router, POST, "/v1/my-module/join", body) and an assertion on kit.mailer.sent().
Public and private modules run the same kit.