Skip to content

Commit af75ce0

Browse files
fix(cdk): resolve ESLint no-require-imports in browser-tool test
1 parent 97c548f commit af75ce0

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

cdk/test/handlers/browser-tool.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ jest.mock('ws', () => {
5757
const msg = JSON.parse(data);
5858
setTimeout(() => {
5959
if (msg.method === 'Page.enable') {
60-
handlers['message']?.forEach(h => h(JSON.stringify({ id: msg.id, result: {} })));
60+
handlers.message?.forEach(h => h(JSON.stringify({ id: msg.id, result: {} })));
6161
} else if (msg.method === 'Page.navigate') {
62-
handlers['message']?.forEach(h => h(JSON.stringify({ id: msg.id, result: { frameId: '1' } })));
63-
handlers['message']?.forEach(h => h(JSON.stringify({ method: 'Page.loadEventFired' })));
62+
handlers.message?.forEach(h => h(JSON.stringify({ id: msg.id, result: { frameId: '1' } })));
63+
handlers.message?.forEach(h => h(JSON.stringify({ method: 'Page.loadEventFired' })));
6464
} else if (msg.method === 'Page.captureScreenshot') {
65-
handlers['message']?.forEach(h => h(JSON.stringify({ id: msg.id, result: { data: 'base64png' } })));
65+
handlers.message?.forEach(h => h(JSON.stringify({ id: msg.id, result: { data: 'base64png' } })));
6666
}
6767
}, 0);
6868
}),
@@ -73,6 +73,7 @@ jest.mock('ws', () => {
7373
});
7474
});
7575

76+
import { StopBrowserSessionCommand } from '@aws-sdk/client-bedrock-agentcore';
7677
import { handler } from '../../src/handlers/browser-tool';
7778

7879
describe('browser-tool handler', () => {
@@ -115,7 +116,6 @@ describe('browser-tool handler', () => {
115116
);
116117

117118
// Verify StopBrowserSession was called
118-
const { StopBrowserSessionCommand } = require('@aws-sdk/client-bedrock-agentcore');
119119
expect(StopBrowserSessionCommand).toHaveBeenCalledWith(
120120
expect.objectContaining({ sessionId: 'session-123' }),
121121
);
@@ -158,7 +158,6 @@ describe('browser-tool handler', () => {
158158
});
159159

160160
// Session should still be stopped even though S3 failed
161-
const { StopBrowserSessionCommand } = require('@aws-sdk/client-bedrock-agentcore');
162161
expect(StopBrowserSessionCommand).toHaveBeenCalledWith(
163162
expect.objectContaining({ sessionId: 'session-456' }),
164163
);

0 commit comments

Comments
 (0)