MCPcopy
hub / github.com/CopilotKit/CopilotKit / setup

Function setup

packages/angular/src/lib/threads.spec.ts:126–172  ·  view source on GitHub ↗

* Sets up a TestBed with the stubbed CopilotKit service and a configurable * fetch mock, and returns helpers for driving the runtime and flushing async * work. Follows the SIFERS pattern.

()

Source from the content-addressed store, hash-verified

124 * work. Follows the SIFERS pattern.
125 */
126function setup() {
127 TestBed.resetTestingModule();
128 stub = new CopilotKitStub();
129 const originalFetch = globalThis.fetch;
130 const fetchMock = vi.fn<typeof fetch>();
131 globalThis.fetch = fetchMock as unknown as typeof fetch;
132
133 TestBed.configureTestingModule({
134 providers: [{ provide: CopilotKit, useValue: stub }],
135 });
136
137 const connect = (
138 options: {
139 list?: boolean;
140 mutations?: boolean;
141 wsUrl?: string;
142 } = {},
143 ): void => {
144 stub.setThreadEndpoints({
145 list: options.list ?? true,
146 inspect: true,
147 mutations: options.mutations ?? true,
148 realtimeMetadata: false,
149 });
150 if (options.wsUrl) {
151 stub.setIntelligence({ wsUrl: options.wsUrl });
152 }
153 stub.setRuntimeUrl("https://runtime.local");
154 stub.setRuntimeConnectionStatus(
155 CopilotKitCoreRuntimeConnectionStatus.Connected,
156 );
157 };
158
159 // Drains the microtask/macrotask queue so the rxjs fetch pipeline (defer →
160 // fromFetch → json() → reducer) and the signal bridges settle.
161 const flush = async (): Promise<void> => {
162 for (let i = 0; i < 5; i += 1) {
163 await new Promise((resolve) => setTimeout(resolve, 0));
164 }
165 };
166
167 const teardown = (): void => {
168 globalThis.fetch = originalFetch;
169 };
170
171 return { stub, fetchMock, connect, flush, teardown };
172}
173
174describe("injectThreads", () => {
175 let active: ReturnType<typeof setup> | undefined;

Callers 1

threads.spec.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…