Commit 21048fb
authored
chore: add testing for A2AExpressApp (#107)
# Description
Add test coverage for A2AExpressApp class.
Added 19 test cases covering all A2AExpressApp functionality:
1. Constructor test: Verifies A2AExpressApp instantiates correctly with
requestHandler and
jsonRpcTransportHandler
2. Setup routes default: Tests setupRoutes works with default parameters
and returns the Express app
3. Setup routes custom baseUrl: Tests setupRoutes accepts and uses a
custom baseUrl parameter
4. Setup routes custom middlewares: Tests setupRoutes accepts and
applies custom middleware array
5. Setup routes custom agentCardPath: Tests setupRoutes accepts custom
agentCardPath parameter
6. Agent card GET default: Tests agent card endpoint returns correct
JSON response at default well-known
path
7. Agent card GET custom path: Tests agent card endpoint works at custom
path when agentCardPath is
specified
8. Agent card error handling: Tests agent card endpoint returns 500
error when getAgentCard fails
9. JSON-RPC single response: Tests POST endpoint handles single JSON-RPC
response correctly
10. JSON-RPC streaming response: Tests POST endpoint handles streaming
responses with Server-Sent Events
11. JSON-RPC streaming error: Tests streaming error handling sends error
event in SSE format
12. JSON-RPC processing error: Tests A2AError handling returns proper
JSON-RPC error response
13. JSON-RPC generic error: Tests non-A2AError fallback returns generic
error response
14. JSON-RPC no ID error: Tests error response includes null ID when
request has no ID
15. Middleware integration: Tests custom middlewares are applied and
called during requests
16. Middleware error handling: Tests middleware errors are properly
handled and return 500
17. Route baseUrl mounting: Tests routes are correctly mounted at
specified baseUrl
18. Route empty baseUrl: Tests routes work correctly when baseUrl is
empty string
19. Express JSON middleware: Tests express.json() middleware is included
by default and parses request
bodies
Dependencies Added:
• Installed supertest and @types/supertest for HTTP endpoint testing
Fixes #105 🦕1 parent 3279c7b commit 21048fb
File tree
3 files changed
+527
-1
lines changed- test/server
3 files changed
+527
-1
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
86 | | - | |
| 88 | + | |
0 commit comments