uploadArchive.test.js - AWS Code Sample

uploadArchive.test.js

const mockUploadArchive = jest.fn(); jest.mock("@aws-sdk/client-glacier/commands/UploadArchiveCommand", () => ({ Glacier: function Glacier() { this.UploadArchiveCommand = mockUploadArchive; }, })); const { run } = require("../../glacier/src/uploadArchive"); //test function test("has to mock glacier#uploadarchive", async (done) => { await run(); expect(mockUploadArchive).toHaveBeenCalled; done(); });