I was musing about what wasm can do for functional programming, and I realized that if you have a pure function in a different module or component, you can still unit test it despite not necessarily having its source code. Has anyone taken advantage of this?
This also led me to think about how WASI could facilitate this. Perhaps you want to access some functions for unit testing purposes in development, but you don't want them exposed in production. Could WASI help with that?
Let me add to this the use case I imagine: Importing in a component that someone else wrote in a programming language you might not know, with behaviors you want to ensure stay consistent as the component is updated over time.
Perhaps WASI would benefit from something similar to dev dependencies?
The guest might have to expose those functions even in production since it is built separately from the host, but the host could ignore them in production builds so you know production will not call them.
I don't think anything special is needed to enable this: components can already export whatever interfaces they choose to, which can then be used by other components however they see fit.
This can be used by having components export additional interfaces in test builds, which are then used by other components that implement the test logic in terms of those interfaces. In production builds, the component under test would not export the testing interfaces, and the test component would not be used at all.
The host doesn't have to know anything about any of this
A related idea I've come back to multiple times is for WIT packages to be able to embed their own conformance tests.
Last updated: Dec 06 2025 at 05:03 UTC