Skip to content

Commit 5140cbc

Browse files
d-csclaude
andcommitted
fix(run-ops test): make engine/marqs no-op mock recursive for nested method access
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 783a700 commit 5140cbc

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

apps/webapp/test/setup.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,18 @@ vi.mock("~/v3/alertsWorker.server", () => ({ alertsWorker: createWorkerStub() })
4242
// that open eager ioredis connections at import via the same pattern. No test
4343
// uses these app-level singletons directly (store-routing tests build their own
4444
// engine and run store), so stub them to no-op proxies.
45-
const noopProxy = () =>
46-
new Proxy(
47-
{},
48-
{
49-
get: () => vi.fn().mockResolvedValue(undefined),
50-
}
51-
);
45+
// Recursive no-op proxy: property access at any depth returns another callable
46+
// no-op proxy, so real service tests reaching nested singleton methods (e.g.
47+
// engine.runQueue.updateEnvConcurrencyLimits) don't break on an intermediate stub.
48+
type NoopProxyFn = ((...args: unknown[]) => Promise<undefined>) & Record<string, unknown>;
49+
50+
const noopProxy = (): NoopProxyFn => {
51+
const fn = () => Promise.resolve(undefined);
52+
return new Proxy(fn, {
53+
get: (_target, prop) => (prop === "then" ? undefined : noopProxy()),
54+
apply: () => Promise.resolve(undefined),
55+
}) as unknown as NoopProxyFn;
56+
};
5257

5358
// Beyond the modules mocked above, dozens more app modules construct an
5459
// ioredis client at import time pointed at env-configured Redis, and ioredis

0 commit comments

Comments
 (0)