You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is related to the fix applied for #256. I spent some time upgrading through releases to find the behavior was working through version 5.5.0 and stopped working with 5.5.1. This may or may not be related to #273.
In my case I was using a fake to implement behavior as follows:
constawsSdkMock=require('aws-sdk-mock')constAWS=require('aws-sdk')const{ describe, it, beforeEach, afterEach }=require('mocha')const{ expect }=require('chai')constsinon=require('sinon')describe('Test case',()=>{beforeEach(()=>{awsSdkMock.setSDKInstance(AWS);});afterEach(()=>{awsSdkMock.restore();sinon.restore();})it('should be able to access parameters',async()=>{// use a fake to mock behavior (works < 5.5.1)constcreateDBSnapshotMock=sinon.fake(params=>{// return the passed in identifier in the responsereturnPromise.resolve({DBSnapshot: {DBSnapshotIdentifier: params.DBSnapshotIdentifier}})})awsSdkMock.mock('RDS','createDBSnapshot',createDBSnapshotMock)constrds=newAWS.RDS()constresult=awaitrds.createDBSnapshot({DBInstanceIdentifier: 'dbInstanceId',DBSnapshotIdentifier: 'snapshotId'}).promise()expect(createDBSnapshotMock.callCount).to.equal(1)expect(createDBSnapshotMock.firstCall.args[0].DBSnapshotIdentifier).to.equal('snapshotId')expect(result.DBSnapshot.DBSnapshotIdentifier).to.equal('snapshotId');})});
The changes in #257 result in the constructed callback spy being passed as the parameters to the fake rather than the parameters to the mocked function.
If I change the fake to accept an extra, unused parameter like this: const createDBSnapshotMock = sinon.fake((params, cb) => { then it results in the parameters being passed as expected since replace.length === 2.
I'm not sure what the proper behavior is in this case and if the second argument for the fake parameters is required.
The text was updated successfully, but these errors were encountered:
I have a second related issue where I'm using a fake to prevent the SDK from executing a call during testing.
// service mock to prevent notification calloutAWS.mock('SNS','publish',sinon.fake())
The fake provides no return value/undefined so typeof result.then logs an error. This tracks back to the changes in #253. The issue does not occur on 5.4.0.
This is related to the fix applied for #256. I spent some time upgrading through releases to find the behavior was working through version 5.5.0 and stopped working with 5.5.1. This may or may not be related to #273.
In my case I was using a fake to implement behavior as follows:
The changes in #257 result in the constructed callback spy being passed as the parameters to the fake rather than the parameters to the mocked function.
If I change the fake to accept an extra, unused parameter like this:
const createDBSnapshotMock = sinon.fake((params, cb) => {
then it results in the parameters being passed as expected sincereplace.length === 2
.I'm not sure what the proper behavior is in this case and if the second argument for the fake parameters is required.
The text was updated successfully, but these errors were encountered: