createTestCapabilities
createTestCapabilities(
overrides?):PlatformCapabilities
Defined in: packages/runtime/src/platform/test-caps.ts:52
Build PlatformCapabilities for use in tests.
Parameters
Section titled “Parameters”overrides?
Section titled “overrides?”Partial<PlatformCapabilities>
Per-method replacements. Merged over the defaults via shallow spread.
Returns
Section titled “Returns”A PlatformCapabilities suitable for test environments.
Remarks
Section titled “Remarks”Returns a stub bag where everything rejects with an explanatory Error
except compileWasm, which
delegates to the host’s WebAssembly.compile (available in Node and
browsers). Tests that actually need a capability pass an overrides
object — typed Partial<PlatformCapabilities> — and only the overridden
methods are replaced. This keeps the failure surface small: an
accidental fetch in a test that didn’t opt into HTTP throws immediately.
Used by testRuntime under the hood; prefer that factory unless you need a bare capability bag for a custom harness.
Example
Section titled “Example”import { createTestCapabilities } from '@fishnet/runtime'
const caps = createTestCapabilities({ async fetch() { return { ok: true, status: 200, text: async () => 'hi', arrayBuffer: async () => new ArrayBuffer(0), json: async () => ({}) } },})