Created
March 3, 2021 23:04
-
-
Save Aposhian/1480087125e7a646c4f28ee699da8cb0 to your computer and use it in GitHub Desktop.
jest aws sdk mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mockFn = (mockResult) => jest.fn(() => ({ | |
promise: () => Promise.resolve(mockResult) | |
})) | |
const implementation = { | |
method1: mockFn({ result1: '' }), | |
method2: mockFn({ result2: '' }), | |
... | |
} | |
jest.mock('aws-sdk', () => ({ | |
CLIENT: jest.fn(() => implementation) | |
})) | |
jest.mock('aws-sdk/clients/CLIENT', () => jest.fn(() => implementation)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment