I'm trying to write out a unit test that stubs the getSignedUrl function from the @aws-sdk/s3-request-presigner package, however when I try stub out the function with sinon, I receive the error:
- TypeError: Descriptor for property getSignedUrl is non-configurable and non-writable
const s3RequestSigner = require("@aws-sdk/s3-request-presigner");
const expect = require('chai').expect;
const sinon = require('sinon')
....
it('should throw an error when getSignedUrl rejects', async function() {
const sandbox = sinon.createSandbox();
sandbox.stub(s3RequestSigner, "getSignedUrl").rejects("fakeUrl");
sandbox.restore();
})
I'm using node.js 16 and writing javascript rather than typescript. Is there a way to mock out my function, i'm struggling to write my tests otherwise?