From a1c013ff3df175a782ba923dff7c278dc97f6fd3 Mon Sep 17 00:00:00 2001 From: Ian Macartney <366683+ianmacartney@users.noreply.github.com> Date: Thu, 8 Oct 2026 23:55:18 -0700 Subject: [PATCH] Return ComponentApi from the test register function This lets convex-test's defineTestApp infer the component's API when the test module is passed directly in its components map. --- src/test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test.ts b/src/test.ts index 0974add..08bb918 100644 --- a/src/test.ts +++ b/src/test.ts @@ -1,6 +1,8 @@ /// import type { TestConvex } from "convex-test"; import type { GenericSchema, SchemaDefinition } from "convex/server"; +import { componentsGeneric } from "convex/server"; +import type { ComponentApi } from "./component/_generated/component.js"; import schema from "./component/schema.js"; const modules = import.meta.glob("./component/**/*.ts"); @@ -8,11 +10,14 @@ const modules = import.meta.glob("./component/**/*.ts"); * Register the component with the test convex instance. * @param t - The test convex instance, e.g. from calling `convexTest`. * @param name - The name of the component, as registered in convex.config.ts. + * @returns a component api to test via ctx.runMutation or for thick client + * usage. Also provides types for convex-test's defineTestApp. */ export function register( t: TestConvex>, name: string = "resend", ) { t.registerComponent(name, schema, modules); + return componentsGeneric()[name] as unknown as ComponentApi; } export default { register, schema, modules };