In my nodejs lambda function I use AWSXray to simply capture https calls made by the function.
const AWSXRay = require("aws-xray-sdk-core");
AWSXRay.captureHTTPsGlobal(require("https"));
In my unit tests how do I mock this?
I have tried mocking it with sinon by:
before(async () =>
await sandbox.stub(AWSXRay, 'captureHTTPsGlobal').returns({})
);
after(async () => {
await sandbox.restore();
});
Getting error in test as:
OperationalError: Failed to get the current sub/segment from the context.
at Object.contextMissingRuntimeError [as contextMissing]