@@ -24,8 +24,10 @@ jest.mock('@aws-sdk/client-bedrock-agentcore', () => ({
2424 StopRuntimeSessionCommand : jest . fn ( ( input : unknown ) => ( { _type : 'StopRuntimeSession' , input } ) ) ,
2525} ) ) ;
2626
27+ import { BedrockAgentCoreClient } from '@aws-sdk/client-bedrock-agentcore' ;
2728import { AgentCoreComputeStrategy } from '../../../../src/handlers/shared/strategies/agentcore-strategy' ;
2829
30+ const MockedClient = jest . mocked ( BedrockAgentCoreClient ) ;
2931const defaultRuntimeArn = 'arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/default' ;
3032
3133beforeEach ( ( ) => {
@@ -72,10 +74,9 @@ describe('AgentCoreComputeStrategy', () => {
7274 } ) ;
7375
7476 test ( 'reuses shared BedrockAgentCoreClient across instances' , async ( ) => {
75- const { BedrockAgentCoreClient } = require ( '@aws-sdk/client-bedrock-agentcore' ) ;
7677 // The lazy singleton may already be initialized from prior tests.
7778 // Record the current call count, then verify no additional constructor calls happen.
78- const callsBefore = BedrockAgentCoreClient . mock . calls . length ;
79+ const callsBefore = MockedClient . mock . calls . length ;
7980
8081 mockSend . mockResolvedValue ( { } ) ;
8182 const strategy1 = new AgentCoreComputeStrategy ( ) ;
@@ -93,7 +94,7 @@ describe('AgentCoreComputeStrategy', () => {
9394 } ) ;
9495
9596 // Lazy singleton: at most one constructor call total across all strategy instances
96- const callsAfter = BedrockAgentCoreClient . mock . calls . length ;
97+ const callsAfter = MockedClient . mock . calls . length ;
9798 expect ( callsAfter - callsBefore ) . toBeLessThanOrEqual ( 1 ) ;
9899 expect ( mockSend ) . toHaveBeenCalledTimes ( 2 ) ;
99100 } ) ;
0 commit comments