ruvnet/ruflo · error

No mock found for ${method} ${url}

Error message

No mock found for ${method} ${url}

What it means

The fetch-mock helper intercepted a request whose method+URL matched none of the registered mock responses (by substring or regex URL and optional method filter). The test helper throws instead of hitting the network, so this means the test forgot to register a mock for that endpoint or the URL/method differs from what was registered.

Source

Thrown at v3/@claude-flow/testing/src/helpers/setup-teardown.ts:466

      fetchResponses.push(...responses);

      if (!originalFetch) {
        originalFetch = global.fetch;

        global.fetch = vi.fn(async (input: string | URL | Request, init?: RequestInit) => {
          const url = typeof input === 'string' ? input : input.toString();
          const method = init?.method ?? 'GET';

          const match = fetchResponses.find(r => {
            const urlMatch = typeof r.url === 'string'
              ? url.includes(r.url)
              : r.url.test(url);
            const methodMatch = !r.method || r.method === method;
            return urlMatch && methodMatch;
          });

          if (!match) {
            throw new Error(`No mock found for ${method} ${url}`);
          }

          if (match.delay) {
            await new Promise(resolve => setTimeout(resolve, match.delay));
          }

          return new Response(JSON.stringify(match.body), {
            status: match.status ?? 200,
            headers: match.headers ?? { 'Content-Type': 'application/json' },
          });
        });
      }
    },

    mockWebSocket(handler: (message: unknown) => unknown): void {
      // WebSocket mocking would require more setup
      // This is a placeholder for the interface
      console.warn('WebSocket mocking not yet implemented');

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Register a mock for the method and URL before issuing the request.
  2. Check the request URL and method match the mock definition exactly.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at v3/@claude-flow/testing/src/helpers/setup-teardown.ts:466 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/f822f3e0040c41f1. Report an issue: GitHub.