Function: checkWiring()
checkWiring<
C>(container,options?):Promise<void>
Defined in: src/utils/check-wiring.ts:119
Checks that everything the container's services need is registered, and with resolve: true that every service can be created. Reports every problem at once: missing keys first (found without running anything), then factories that throw, each with the services it affects. Resolves when there is nothing to report, and rejects with a WiringError otherwise.
Use it in a test. To create services at startup, use preload.
Type Parameters
C
C extends ServiceProvider<{ }> | AsyncServiceProvider<{ }>
Parameters
container
C
options?
CheckWiringOptions<keyof ContainerServices<C>> = {}
Returns
Promise<void>
Examples
Check the wiring without running factories
it('wires every service', async () => {
await checkWiring(createApp());
});Also run every factory, with fakes for the outside world
await using test = createApp()
.fork({ isolated: true })
.addInstance('db', fakeDb, { replace: true });
await checkWiring(test, { resolve: true });Services the compiler can't see: list the declared keys
const declared = { clock: true, greeter: true } satisfies Record<keyof Services, true>;
await checkWiring(app, { keys: Object.keys(declared) as (keyof Services)[] });