cwe_putevents.test.js - AWS Code Sample

cwe_putevents.test.js

const mockPutEvents = jest.fn(); jest.mock( "@aws-sdk/client-cloudwatch-events/commands/PutEventsCommand", () => ({ CloudWatch: function CloudWatch() { this.PutEventsCommand = mockPutEvents; }, }) ); const { params, run } = require("../../cloudwatch/src/cwe_putevents"); //test function test("has to mock cloudwatch-events#putevents", async (done) => { await run(); expect(mockPutEvents).toHaveBeenCalled; done(); });