Repository navigation
test: add unit tests for TypeScript ChainAgent and BedrockFlowsAgent - #540
nuthalapativarun wants to merge 2 commits into
Conversation
|
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! |
|
This test PR fills a useful gap, but the reviewer note about required behavior should probably become part of the assertions. For |
…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. |
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
…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.
f3f67be to
ae849ef
Compare
|
Rebased this branch onto current Force-pushed the rebased branch. Ran the TS suite scoped to Since prior comments noted CI had never triggered on this branch, this push should let it run. @cornelcroi could you kick off a CI run and take another look when you have a chance? |
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.