Skip to content

Commit 035a9aa

Browse files
committed
improve test.ts
1 parent d596657 commit 035a9aa

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

template-component/src/test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
import type { TestConvex } from "convex-test";
2+
import type { GenericSchema, SchemaDefinition } from "convex/server";
13
import schema from "./component/schema.js";
24
const modules = import.meta.glob("./component/**/*.ts");
3-
export default { schema, modules };
5+
6+
/**
7+
* Register the component with the test convex instance.
8+
* @param t - The test convex instance, e.g. from calling `convexTest`.
9+
* @param name - The name of the component, as registered in convex.config.ts.
10+
*/
11+
function register(
12+
t: TestConvex<SchemaDefinition<GenericSchema, boolean>>,
13+
name: string = "shardedCounter"
14+
) {
15+
t.registerComponent(name, schema, modules);
16+
}
17+
export default { register, schema, modules };

0 commit comments

Comments
 (0)