Skip to content

Commit 21048fb

Browse files
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

3 files changed

+527
-1
lines changed

package-lock.json

Lines changed: 171 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@types/mocha": "^10.0.10",
4848
"@types/node": "^22.13.14",
4949
"@types/sinon": "^17.0.4",
50+
"@types/supertest": "^6.0.3",
5051
"c8": "^10.1.3",
5152
"chai": "^5.2.0",
5253
"express": "^5.1.0",
@@ -55,6 +56,7 @@
5556
"json-schema-to-typescript": "^15.0.4",
5657
"mocha": "^11.6.0",
5758
"sinon": "^20.0.0",
59+
"supertest": "^7.1.4",
5860
"tsup": "^8.5.0",
5961
"tsx": "^4.19.3",
6062
"typescript": "^5.8.2"
@@ -83,4 +85,4 @@
8385
"mocha": {
8486
"require": "tsx"
8587
}
86-
}
88+
}

0 commit comments

Comments
 (0)