sns_subscribeemail.test.js - AWS Code Sample

sns_subscribeemail.test.js

const mockSubscribe = jest.fn(); jest.mock("@aws-sdk/client-sns/commands/SubscribeCommand", () => ({ SNS: function SNS() { this.SubscribeCommand = mockSubscribe; }, })); const { run } = require("../../sns/src/sns_subscribeemail.js"); //test function test("has to mock SNS#subscribeemail", async (done) => { await run(); expect(mockSubscribe).toHaveBeenCalled; done(); });