sqs_receivemessage.test.js - AWS Code Sample

sqs_receivemessage.test.js

const mockReceiveMessages = jest.fn(); jest.mock("@aws-sdk/client-sqs/commands/ReceiveMessageCommand", () => ({ SQS: function SQS() { this.ReceiveMessageCommand = mockReceiveMessages; }, })); const { run } = require("../../sqs/src/sqs_receivemessage.js"); //test function test("has to mock SQS#receivemessage", async (done) => { await run(); expect(mockReceiveMessages).toHaveBeenCalled; done(); });