Example:
const AWSMock = require("aws-sdk-mock");
import AWS = require("aws-sdk");
AWSMock.setSDKInstance(AWS);
import "mocha";
import { expect } from "chai";
const base_url = "test.yourdomain.com";
const host = `https://${base_url}`;
const path = "/api/user";
describe("TEST SSM", function() {
it("should mock SSM getParameter", async () => {
// Overwriting SSM getParameter()
AWSMock.setSDKInstance(AWS);
AWSMock.mock("SSM", "getParameter", {
Parameter: {
Name: "/order/main/endpoint/base-url",
Type: "String",
Value: base_url,
Version: 1,
LastModifiedDate: 1562226288.85,
ARN: "arn:aws:ssm:us-west-1:123:/order/main/endpoint/base-url"
}
});
const ssm = new AWS.SSM();
const params = {
Name: "/order/main/endpoint/base-url",
WithDecryption: false
};
const result = await ssm.getParameter(params).promise();
const value = result.Parameter ? result.Parameter.Value : "";
expect(result.Parameter).to.be.an("object");
expect(value).to.equal(base_url);
AWSMock.restore("SSM");
});
});