Skip to main content

Function: instrumentDOProject()

instrumentDOProject(configOrSourceModule): InstrumentedDOProject

Defined in: testing/src/instrument-do-project.ts:120

Instruments a DO project for testing by wrapping DO classes with lumenizeRpcDO and creating a worker that routes RPC requests.

This eliminates the need for boilerplate test-harness.ts files - the function handles all the instrumentation automatically.

Auto-detection uses prototype chain walking (instanceof DurableObject) to reliably distinguish DOs from WorkerEntrypoints and other class exports. Non-DO classes are automatically passed through (unwrapped) on the result object.

Zero-config (most projects):

// test/test-harness.ts — works even with mixed DO + WorkerEntrypoint exports
import * as sourceModule from '../src';
import { instrumentDOProject } from '@lumenize/testing';

export default instrumentDOProject(sourceModule);

Explicit configuration (when auto-detection can't determine what to do):

const { worker, dos } = instrumentDOProject({
sourceModule,
doClassNames: ['MyDO', 'AnotherDO']
});

export const { MyDO, AnotherDO } = dos;
export default worker;

Parameters

configOrSourceModule

any

Returns

InstrumentedDOProject