MCPcopy Create free account
hub / github.com/agentrpc/agentrpc / testService

Function testService

sdk-node/src/agentrpc.test.ts:13–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11import { http, HttpResponse, passthrough } from "msw";
12
13const testService = () => {
14 const client = testInstance();
15 const prefix = `test${Math.random().toString(36).substring(2, 15)}`;
16
17 client.register({
18 name: `${prefix}_echo`,
19 handler: async (input: { text: string }) => {
20 return { echo: input.text };
21 },
22 schema: z.object({
23 text: z.string(),
24 }),
25 });
26
27 client.register({
28 name: `${prefix}_error`,
29 handler: async (_input) => {
30 throw new Error("This is an error");
31 },
32 schema: z.object({
33 text: z.string(),
34 }),
35 });
36
37 return {
38 client,
39 prefix,
40 };
41};
42
43describe("AgentRPC", () => {
44 const env = process.env;

Callers 1

agentrpc.test.tsFile · 0.70

Calls 2

testInstanceFunction · 0.90
registerMethod · 0.80

Tested by

no test coverage detected