Skip to content
WebMCP Agents
Esc
↑↓navigate↵open⌘Jpreview
On this page

toHaveStructuredContent

The tool result's structuredContent has these keys with these values.

Passes when a tool result’s structuredContent has the given keys with the given values. It is a partial match: other keys may be there.

Import

import "@webmcp-agents/testing/matchers"; // in setupFiles (the main entry and ./setup register them too)

Example

expect(await tools.call("cart_total")).toHaveStructuredContent({ total: 48 });

Options

expect(received).toHaveStructuredContent(expected).

Name Type Default Description
expected Record<string, unknown> required The keys to check and their values (compared deeply; asymmetric matchers work).

Returns

Nothing: it passes, or fails the test with a message that says what happened.

Notes

A failure names each key that differs, with both values. A result without structuredContent says so.

See also

Was this page helpful?