2323 * otherwise a real request is made and the response is recorded.
2424 * To re-record all responses, set the NOCK_BACK_MODE environment variable
2525 * to 'update' - when recording responses, valid AWS credentials for
26- * accessing bedrock are also required.
26+ * accessing bedrock are also required. To record for new tests while
27+ * keeping existing recordings, set NOCK_BACK_MODE to 'record'.
2728 */
2829
2930import {
@@ -39,6 +40,7 @@ import {
3940 ConversationRole ,
4041 InvokeModelCommand ,
4142} from '@aws-sdk/client-bedrock-runtime' ;
43+ import { AwsCredentialIdentity } from '@aws-sdk/types' ;
4244import * as path from 'path' ;
4345import { Definition , back as nockBack } from 'nock' ;
4446
@@ -77,13 +79,17 @@ const sanitizeRecordings = (scopes: Definition[]) => {
7779} ;
7880
7981describe ( 'Bedrock' , ( ) => {
80- const client = new BedrockRuntimeClient ( { region } ) ;
81-
8282 nockBack . fixtures = path . join ( __dirname , 'mock-responses' ) ;
83- if ( ! process . env . NOCK_BACK_MODE ) {
84- nockBack . setMode ( 'record' ) ;
83+ let credentials : AwsCredentialIdentity | undefined ;
84+ if ( nockBack . currentMode === 'dryrun' ) {
85+ credentials = {
86+ accessKeyId : 'testing' ,
87+ secretAccessKey : 'testing' ,
88+ } ;
8589 }
8690
91+ const client = new BedrockRuntimeClient ( { region, credentials } ) ;
92+
8793 let nockDone : ( ) => void ;
8894 beforeEach ( async function ( ) {
8995 const filename = `${ this . currentTest
0 commit comments