@@ -25,13 +25,21 @@ describe('UserCredentialsUtils', function () {
2525 let tempFolder : string
2626 let defaultConfigFileName : string
2727 let defaultCredentialsFilename : string
28+ // preserve envs
29+ const credEnv = process . env [ 'AWS_SHARED_CREDENTIALS_FILE' ]
30+ const configEnv = process . env [ 'AWS_CONFIG_FILE' ]
2831
2932 before ( async function ( ) {
30- defaultConfigFileName = getConfigFilename ( )
31- defaultCredentialsFilename = getCredentialsFilename ( )
3233 // Make a temp folder for all these tests
3334 // Stick some temp credentials files in there to load from
3435 tempFolder = await makeTemporaryToolkitFolder ( )
36+
37+ // Set env to fake cred/config to avoid the actual aws config being deleted by test
38+ process . env . AWS_SHARED_CREDENTIALS_FILE = path . join ( tempFolder , 'aws-credentials-tmp' )
39+ process . env . AWS_CONFIG_FILE = path . join ( tempFolder , 'aws-config-tmp' )
40+
41+ defaultConfigFileName = getConfigFilename ( )
42+ defaultCredentialsFilename = getCredentialsFilename ( )
3543 } )
3644
3745 afterEach ( async function ( ) {
@@ -43,6 +51,9 @@ describe('UserCredentialsUtils', function () {
4351
4452 after ( async function ( ) {
4553 await fs . delete ( tempFolder , { recursive : true } )
54+ // restore envs
55+ process . env [ 'AWS_SHARED_CREDENTIALS_FILE' ] = credEnv
56+ process . env [ 'AWS_CONFIG_FILE' ] = configEnv
4657 } )
4758
4859 describe ( 'findExistingCredentialsFilenames' , function ( ) {
0 commit comments