Skip to content

Instantly share code, notes, and snippets.

@Aposhian
Created March 3, 2021 23:04
Show Gist options
  • Save Aposhian/1480087125e7a646c4f28ee699da8cb0 to your computer and use it in GitHub Desktop.
Save Aposhian/1480087125e7a646c4f28ee699da8cb0 to your computer and use it in GitHub Desktop.
jest aws sdk mock
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