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

toHaveBeenOfferedTools

Every model step of the mock adapter was offered these tools.

Reads a mockAdapter, which records the tools offered on every model step. Passes when every step was offered each listed tool (others may be offered too), or when every step’s names satisfy the asymmetric matcher.

Import

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

Example

expect(adapter).toHaveBeenOfferedTools(["search_products", "add_to_cart"]);
expect(adapter).toHaveBeenOfferedTools(expect.not.arrayContaining(["place_order"]));

Options

expect(received).toHaveBeenOfferedTools(expected).

Name Type Default Description
expected string[] | asymmetric matcher required Tools each step was offered, or a matcher over each step’s names.

Returns

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

Notes

A failure names the first step that was not offered them, what it was offered, and what was missing.

To say that no step was offered a tool, use the asymmetric form, one tool per assertion (expect.not.arrayContaining(["a", "b"]) also matches a step offered only a). Negated with a list (.not.toHaveBeenOfferedTools(["place_order"])) the matcher refuses to run: it would pass as soon as one step was not offered the tool, even if another was. An adapter that has not run fails either way, negated too.

See also

Was this page helpful?