Skip to content

Add Phantom.Test framework for asserting on tools, prompts, and resources#22

Draft
dbernheisel wants to merge 1 commit intomainfrom
dbern/add-test-helpers
Draft

Add Phantom.Test framework for asserting on tools, prompts, and resources#22
dbernheisel wants to merge 1 commit intomainfrom
dbern/add-test-helpers

Conversation

@dbernheisel
Copy link
Copy Markdown
Owner

@dbernheisel dbernheisel commented May 4, 2026

Closes #15.

Phantom.Test is a framework for unit-testing MCP routers without booting an HTTP transport.

  • Blocking dispatchers (call_tool, read_resource, get_prompt, complete_prompt, complete_resource, list_resources) return the final response whether the handler replied sync or async via Session.respond/2.
  • Final-response and side-channel matchers (tool/resource/prompt content, JSON-RPC errors, :elicitation_required, progress notifications, client logs) live on the same module.
  • expect_elicit/1 / expect_elicit_url/1 settle handlers that block on Session.elicit/2 (sync or from a spawned Task).
  • phoenix_pubsub stays optional. Phantom.Test.start/1 only starts Phantom.Tracker when :pubsub is passed.
  • Phantom.Test.TimeoutError raised at the call site when an async handler doesn't respond in :timeout (default 1000ms).

Phantom.Test.Conn (transport-level escape hatch) is not in this PR — the existing internal dispatcher still backs the library's own integration tests.

@dbernheisel dbernheisel force-pushed the dbern/add-test-helpers branch 3 times, most recently from 555d41b to fd77ce5 Compare May 4, 2026 02:28
@dbernheisel dbernheisel force-pushed the dbern/add-test-helpers branch from fd77ce5 to b319989 Compare May 4, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: ship a Phantom.Test framework for asserting tools, prompts, and resources

1 participant