@moult/test
v0.1.2
Published
Public test host utilities for proving Moult ownership and replacement behavior.
Maintainers
Readme
@moult/test
Public test-host utilities for proving Moult ownership, replacement, disposal, and leak behavior.
Installation
npm install --save-dev @moult/test @moult/runtimeRequires Node.js 22 or newer.
Example
The test kit uses only the public runtime API and makes resource ownership observable without reading runtime internals.
import { capability } from '@moult/runtime';
import { expectGenerationDisposed, fakeResources, pluginHarness } from '@moult/test';
const resources = fakeResources();
const ready = capability<{ readonly ok: true }>('example.ready', '1.0.0');
const harness = pluginHarness({
id: 'example.plugin',
version: '1.0.0',
provides: [{ capability: ready }],
setup: async (context) => {
const connection = resources.connectionHost();
await context.scope.acquire(connection.create, connection.dispose);
context.provide(ready, { ok: true });
},
});
await harness.run();
await harness.dispose();
await expectGenerationDisposed(harness.runtime, 'example.plugin');
resources.expectNoLeaks();Features
fakeResourcescreates observable connections, listeners, timers, and failing resources.pluginHarnessruns setup-level tests against the public runtime contract.expectGenerationDisposedverifies that a generation is no longer retained.resources.expectNoLeaks()verifies that all tracked resources were released.- Failure cues make resource creation and disposal deterministic.
This is a development and test package. It does not provide lifecycle behavior for production applications and does not import Moult internals.
Public API
The package exports fakeResources, pluginHarness,
expectGenerationDisposed, and the public fake-resource and harness types.
Status and documentation
Implemented and published. See the Moult repository, the adapter design, and the lifecycle guarantees.
