UNPKG

@odel/module-sdk

Version:

SDK for building Odel modules - MCP protocol over HTTP for Cloudflare Workers

37 lines 1.08 kB
/** * Test assertion helpers for Odel modules */ /** * Assert that a result is a success response * * @param result - Response from tool execution * @throws Error if result is not a success response * * @example * ```typescript * const result = await testTool(worker, 'add', { a: 1, b: 2 }); * expectSuccess(result); * expect(result.result).toBe(3); * ``` */ export declare function expectSuccess<T = any>(result: any): asserts result is { success: true; } & T; /** * Assert that a result is an error response * * @param result - Response from tool execution * @param messagePattern - Optional pattern to match against error message * @throws Error if result is not an error response or doesn't match pattern * * @example * ```typescript * const result = await testTool(worker, 'divide', { a: 1, b: 0 }); * expectError(result, /cannot divide by zero/i); * ``` */ export declare function expectError(result: any, messagePattern?: string | RegExp): asserts result is { success: false; error: string; }; //# sourceMappingURL=assertions.d.ts.map