Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Setup fixed credentials for dryrun mode
  • Loading branch information
anuraaga committed Mar 19, 2025
commit ae73969b992439be2da6a6b4f3c7cab840537a3a
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
* otherwise a real request is made and the response is recorded.
* To re-record all responses, set the NOCK_BACK_MODE environment variable
* to 'update' - when recording responses, valid AWS credentials for
* accessing bedrock are also required.
* accessing bedrock are also required. To record for new tests while
* keeping existing recordings, set NOCK_BACK_MODE to 'record'.
*/

import {
Expand All @@ -39,6 +40,7 @@ import {
ConversationRole,
InvokeModelCommand,
} from '@aws-sdk/client-bedrock-runtime';
import { AwsCredentialIdentity } from '@aws-sdk/types';
import * as path from 'path';
import { Definition, back as nockBack } from 'nock';

Expand Down Expand Up @@ -77,13 +79,17 @@ const sanitizeRecordings = (scopes: Definition[]) => {
};

describe('Bedrock', () => {
const client = new BedrockRuntimeClient({ region });

nockBack.fixtures = path.join(__dirname, 'mock-responses');
if (!process.env.NOCK_BACK_MODE) {
nockBack.setMode('record');
let credentials: AwsCredentialIdentity | undefined;
if (nockBack.currentMode === 'dryrun') {
credentials = {
accessKeyId: 'testing',
secretAccessKey: 'testing',
};
}

const client = new BedrockRuntimeClient({ region, credentials });

let nockDone: () => void;
beforeEach(async function () {
const filename = `${this.currentTest
Expand Down
Loading