Skip to content

Commit 4b004a3

Browse files
fix: resolve ESLint errors in test files
- Replace require() with ES import for BedrockAgentCoreClient mock - Fix import ordering in start-session-composition test
1 parent d68edd6 commit 4b004a3

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

cdk/test/handlers/shared/strategies/agentcore-strategy.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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';
2728
import { AgentCoreComputeStrategy } from '../../../../src/handlers/shared/strategies/agentcore-strategy';
2829

30+
const MockedClient = jest.mocked(BedrockAgentCoreClient);
2931
const defaultRuntimeArn = 'arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/default';
3032

3133
beforeEach(() => {
@@ -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
});

cdk/test/handlers/start-session-composition.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ process.env.RUNTIME_ARN = 'arn:aws:bedrock-agentcore:us-east-1:123456789012:runt
6767
process.env.MAX_CONCURRENT_TASKS_PER_USER = '3';
6868
process.env.TASK_RETENTION_DAYS = '90';
6969

70+
import { TaskStatus } from '../../src/constructs/task-status';
7071
import { resolveComputeStrategy } from '../../src/handlers/shared/compute-strategy';
7172
import { transitionTask, emitTaskEvent, failTask } from '../../src/handlers/shared/orchestrator';
72-
import { TaskStatus } from '../../src/constructs/task-status';
7373
import type { BlueprintConfig } from '../../src/handlers/shared/repo-config';
7474

7575
beforeEach(() => {

0 commit comments

Comments
 (0)