test: add unit tests for TypeScript ChainAgent and BedrockFlowsAgent#540
test: add unit tests for TypeScript ChainAgent and BedrockFlowsAgent#540nuthalapativarun wants to merge 2 commits into
Conversation
Adds ChainAgent.test.ts (12 tests) covering constructor validation, the chaining pipeline, passthrough of additionalParams, streaming on the last agent, error propagation, and defaultOutput fallback. Adds BedrockFlowsAgent.test.ts (8 tests) covering constructor options, processRequest happy path, custom encoder/decoder, missing response stream, and client error wrapping. Closes 2FastLabs#539
|
Hey @nuthalapativarun, nice work — One thing that needs to be fixed before merging: Required: In the Smaller things (non-blocking):
Otherwise this looks good to go! |
…tring Addresses review feedback on PR 2FastLabs#540: the error-propagation test used rejects.toMatch instead of the repo convention rejects.toThrow. Switching the assertion alone couldn't pass because ChainAgent's catch block threw a raw template-literal string rather than an Error, and Jest's toThrow cannot detect non-Error rejections. Updated ChainAgent to throw new Error(...) with the extracted message, matching the pattern already used in BedrockFlowsAgent.
|
Thanks for the catch, @cornelcroi! Updated the ChainAgent error test to use One wrinkle: switching the matcher alone couldn't actually pass, because Pushed as f3f67be. Ready for re-review. |
Issue Link (REQUIRED)
Fixes #539
Summary
Changes
Adds unit test coverage for two previously untested TypeScript agents:
ChainAgent.test.ts(12 tests)processRequest: single-agent pass-through, multi-agent pipeline (output of agent N becomes input to agent N+1),additionalParamsforwarded to every agent, default response on empty content, last-agent streaming allowed, intermediate streaming returns default response, agent error propagatesBedrockFlowsAgent.test.ts(8 tests)enableTracedefault/setprocessRequest: happy-path flow invocation + decode, missing response stream error, customflowInputEncoder, customflowOutputDecoder, client-level error wrappingBoth files follow the same mock/describe/it structure as the existing
LambdaAgent.test.ts.User experience
Before:
npx jestproduced no output forChainAgentorBedrockFlowsAgent.After: 20 new assertions covering the core behaviour and error paths of both agents.
Checklist
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.