toHaveResources
Checks that an MCP server provides all of the specified resources. This matcher works with MCPStdinSubprocess
instances.
Syntax
await expect(app).toHaveResources(resourceNames);
Parameters
resourceNames
: An array of resource names to check for
Example
import { mcpShell } from 'expect-mcp';
import { test, expect } from 'vitest';
test('server provides configuration resources', async () => {
const app = mcpShell('node config-server.js');
await app.initialize();
await expect(app).toHaveResources(['app_config', 'user_settings']);
app.close();
});
Error Messages
If any of the resources don't exist:
await expect(app).toHaveResources(['app_config', 'nonexistent_resource']);
// Error: Expected server to have all resources ["app_config", "nonexistent_resource"], but "nonexistent_resource" was not found.
// Available resources: app_config, user_settings
See Also
- toHaveResource - Check for a single resource
- toHaveTool - Check for tools
- mcpShell - Create an MCP subprocess